Re: Q: Escapes in jsonpath Idents
David E. Wheeler <david@justatheory.com>
From: "David E. Wheeler" <david@justatheory.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Erik Wienhold <ewie@ewie.name>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2024-04-24T11:52:37Z
Lists: pgsql-hackers
On Apr 24, 2024, at 05:51, Peter Eisentraut <peter@eisentraut.org> wrote:
> A <JSON path identifier> is classified as follows.
>
> Case:
>
> a) A <JSON path identifier> that is a <dollar sign> is a <JSON path
> context variable>.
>
> b) A <JSON path identifier> that begins with <dollar sign> is a
> <JSON path named variable>.
>
> c) Otherwise, a <JSON path identifier> is a <JSON path key name>.
>
> Does this help? I wasn't following all the discussion to see if there is anything wrong with the implementation.
Yes, it does, as it ties the special meaning of the dollar sign to the *beginning* of an expression. So it makes sense that this would be an error:
david=# select '$.$foo'::jsonpath;
ERROR: syntax error at or near "$foo" of jsonpath input
LINE 1: select '$.$foo'::jsonpath;
^
But I’m less sure when a dollar sign is used in the *middle* (or end) of a json path identifier:
david=# select '$.xx$foo'::jsonpath;
ERROR: syntax error at or near "$foo" of jsonpath input
LINE 1: select '$.xx$foo'::jsonpath;
^
Perhaps that should be valid?
Best,
David
Commits
-
doc: Correct jsonpath string literal escapes description
- a8457887c3c1 12.19 landed
- b51dff73fa73 13.15 landed
- 630ed7ec4d36 14.12 landed
- feb19bf5081f 15.7 landed
- a7ed15f3ab81 16.3 landed
- b279e37015bb 17.0 landed