Re: JSONPath operator and escaping values in query

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Vasu Nagendra <vasu(at)termtegrity(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: JSONPath operator and escaping values in query
Date: 2024-07-05 01:11:47
Message-ID: CAKFQuwate+AcOjqjSPhE7W-DAdb6X+mnZVB21rZbVyotLkb1OQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 4, 2024 at 1:57 PM Vasu Nagendra <vasu(at)termtegrity(dot)com> wrote:

>
>
> SELECT '{"n": {"a-b": 1, "@ab": 2, "ab": 3}}'::jsonb @? '$ ? (@.n.a\-b >= 3)';
>
>
Which is better written as:

select '{"n": {"a-b": 1, "@ab": 2, "ab": 3}}'::jsonb @? '$ ? (@.n."a-b" >=
3)';

Using the same double-quotes you defined the key with originally.

The relevant documentation for jsonpath syntax is here:

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

David J.

>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2024-07-05 01:16:32 Re: psql help
Previous Message Murthy Nunna 2024-07-04 23:56:03 psql help