JSONPath Child Operator?

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

JSONPath Child Operator?

От:
"David E. Wheeler" <david@justatheory.com>
Дата:
Greetings! Long time no see, I know. How are you, Hackers?

I notice from the docs in the Postgres JSONPath type, brackets are described as:

> • Square brackets ([]) are used for array access.


  https://www.postgresql.org/docs/current/datatype-json.html#DATATYPE-JSONPATH

Notably they are not used for object field path specifications, in contrast to the original JSON Path design, which says:

> JSONPath expressions can use the dot–notation
> 
> $.store.book[0].title
> 
> or the bracket–notation
> 
> $['store']['book'][0]['title']

  https://goessner.net/articles/JsonPath/index.html#e2

Similarly, the current IETF RFC Draft says:

> JSONPath expressions use the _bracket notation_, for example:
> 
>    $['store']['book'][0]['title']
> 
>    or the more compact _dot notation_, for example:
> 
>    $.store.book[0].title

  https://datatracker.ietf.org/doc/draft-ietf-jsonpath-base/


My question: Are there plans to support square bracket syntax for JSON object field name strings like this? Or to update to follow the standard as it’s finalized?

Thanks,

David



Re: JSONPath Child Operator?

От:
Filipp Krylov <phil@krylov.eu>
Дата:
Hi David,

On 2022-11-10 21:55, David E. Wheeler wrote:
> My question: Are there plans to support square bracket syntax for JSON 
> object field name strings like this? Or to update to follow the 
> standard as it’s finalized?

This syntax is a part of "jsonpath syntax extensions" patchset: 
https://www.postgresql.org/message-id/e0fe4f7b-da0b-471c-b3da-d8adaf314357%40postgrespro.ru

-- Ph.


Re: JSONPath Child Operator?

От:
David E. Wheeler <david@justatheory.com>
Дата:
On Jan 30, 2023, at 08:17, Filipp Krylov  wrote:

>> My question: Are there plans to support square bracket syntax for JSON object field name strings like this? Or to update to follow the standard as it’s finalized?
> 
> This syntax is a part of "jsonpath syntax extensions" patchset: https://www.postgresql.org/message-id/e0fe4f7b-da0b-471c-b3da-d8adaf314357%40postgrespro.ru

Nice, thanks. I learned since sending this email that SQL/JSON Path is not at all the same as plain JSON Path, so now I’m less concerned bout it. I like the new object subscript syntax, though, I’ve been thinking about this myself.

D



FAQ