Re: Re: SQL/JSON: functions - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: Re: SQL/JSON: functions
Date
Msg-id CAPpHfduLcQzTOMrVe9+_d0te=LAmY-2OL9Kcn+yBq8h1HYPZSg@mail.gmail.com
Whole thread Raw
In response to Re: Re: SQL/JSON: functions  (Andrew Alsup <bluesbreaker@gmail.com>)
List pgsql-hackers
Hi!

On Tue, May 14, 2019 at 3:54 AM Andrew Alsup <bluesbreaker@gmail.com> wrote:
> array slicing [0:], [:1], and [0:1] do not work:$.c1.c2[0:].b3
>
> # select json_path_query('{"a1": 123, "b1": "xxx", "c1": {"a2": 456,
> "b2": "yyy", "c2": [{"a3": 777, "b3": "7z"},{"a3": 888, "b3":
> "8z"}]}}'::json, '$.c1.c2[0:].b3'::jsonpath);
> 2019-05-13 20:47:48.740 EDT [21856] ERROR:  bad jsonpath representation
> at character 147
> 2019-05-13 20:47:48.740 EDT [21856] DETAIL:  syntax error, unexpected
> ':', expecting ',' or ']' at or near ":"
> 2019-05-13 20:47:48.740 EDT [21856] STATEMENT:  select
> json_path_query('{"a1": 123, "b1": "xxx", "c1": {"a2": 456, "b2": "yyy",
> "c2": [{"a3": 777, "b3": "7z"},{"a3": 888, "b3": "8z"}]}}'::json,
> '$.c1.c2[0:].b3'::jsonpath);
> ERROR:  bad jsonpath representation
> LINE 1: ...7, "b3": "7z"},{"a3": 888, "b3": "8z"}]}}'::json, '$.c1.c2[0...
>                                                               ^
> DETAIL:  syntax error, unexpected ':', expecting ',' or ']' at or near ":"

There is no color syntax from array slicing in jsonpath.  Instead of
"[0:]" one should write "[0 to last]".  See documentation
https://www.postgresql.org/docs/devel/datatype-json.html#TYPE-JSONPATH-ACCESSORS

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Avoiding hash join batch explosions with extreme skew and weird stats
Next
From: Kyotaro HORIGUCHI
Date:
Subject: Re: VACUUM fails to parse 0 and 1 as boolean value