Re: Cast json array to postgres array and preserve order of elements

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: Cast json array to postgres array and preserve order of elements
Дата
Msg-id 70e3c24d-317a-5469-426e-c8b8da91ab72@2ndQuadrant.com
обсуждение исходный текст
Ответ на Cast json array to postgres array and preserve order of elements  (otar shavadze <oshavadze@gmail.com>)
Ответы Re: Cast json array to postgres array and preserve order of elements  (otar shavadze <oshavadze@gmail.com>)
Список pgsql-hackers
On 5/10/20 8:21 AM, otar shavadze wrote:
> When I want t to convert json array into postgres array, I do:
>
>     with t(j) as(
>         select '{"my_arr":[3,1,2]}'::json
>     )
>     SELECT ARRAY(SELECT json_array_elements_text(j->'my_arr')) from t
>
>
> It works like a charm and I never noticed any problem, but I'm asking
> here just to make sure,  order of elements will be preserved always? 
> Is that guaranteed in above example, or not?
>
>


yes. The order is significant and the elements are produced in array order.


cheers


andrew


-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




В списке pgsql-hackers по дате отправления:

Предыдущее
От: godjan •
Дата:
Сообщение: Re: Strange decreasing value of pg_last_wal_receive_lsn()
Следующее
От: otar shavadze
Дата:
Сообщение: Re: Cast json array to postgres array and preserve order of elements