Re: Q: Escapes in jsonpath Idents

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Q: Escapes in jsonpath Idents
Date: 2024-04-24 11:52:37
Message-ID: 6D3DD5E4-61B8-4E5D-8B29-50A1C0E6BBE5@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Apr 24, 2024, at 05:51, Peter Eisentraut <peter(at)eisentraut(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2024-04-24 11:53:33 Re: Q: Escapes in jsonpath Idents
Previous Message Daniel Gustafsson 2024-04-24 11:31:12 Re: Cutting support for OpenSSL 1.0.1 and 1.0.2 in 17~?