Re: [GENERAL] JSON to INT[] or other custom type
| От | Bruno Wolff III |
|---|---|
| Тема | Re: [GENERAL] JSON to INT[] or other custom type |
| Дата | |
| Msg-id | 20170612012213.GA31918@wolff.to обсуждение исходный текст |
| Ответ на | [GENERAL] JSON to INT[] or other custom type (Rory Campbell-Lange <rory@campbell-lange.net>) |
| Ответы |
Re: [GENERAL] JSON to INT[] or other custom type
|
| Список | pgsql-general |
On Sun, Jun 11, 2017 at 22:35:14 +0100,
Rory Campbell-Lange <rory@campbell-lange.net> wrote:
>
>I'm hoping, in the plpgsql function, to unfurl the supplied json into a
>custom type or at least an array of ints, and I can't work out how to do
>that.
>
> select * from json_array_elements_text('[[0, 1], [1, 2]]');
> value
> --------
> [0, 1]
> [1, 2]
> (2 rows)
>
>works fine, but I can't seem to turn those values into actual ints or
>anything else for that matter, apart from text via the
>json_array_elements_text() function.
Does this example help?
area=> select (a->>0)::int, (a->>1)::int from json_array_elements('[[0, 1], [1, 2]]') as s(a);
int4 | int4
------+------
0 | 1
1 | 2
(2 rows)
В списке pgsql-general по дате отправления: