Обсуждение: Example of json_array_elements

Поиск
Список
Период
Сортировка

Example of json_array_elements

От
PG Doc comments form
Дата:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/functions-json.html
Description:

Maybe this example for json_array_elements is wrong?

select * from json_array_elements('[1,true, [2,false]]')

It seems to me that it should be

select * from json_array_elements('[[1,true], [2,false]]')

Thank you for this extraordinary documentation!

Re: Example of json_array_elements

От
Daniel Gustafsson
Дата:
> On 12 Nov 2021, at 13:18, PG Doc comments form <noreply@postgresql.org> wrote:

> Maybe this example for json_array_elements is wrong?

No, the example works as intended and yields the output in the documentation:

postgres=# select * from json_array_elements('[1,true, [2,false]]');
   value
-----------
 1
 true
 [2,false]
(3 rows)

Your proposal is also syntactically correct, but it's not what the author
intended when writing the example:

postgres=# select * from json_array_elements('[[1,true], [2,false]]');
   value
-----------
 [1,true]
 [2,false]
(2 rows)

--
Daniel Gustafsson        https://vmware.com/