public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Vasu Nagendra <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: JSONPath operator and escaping values in query
Date: Thu, 4 Jul 2024 18:11:47 -0700
Message-ID: <CAKFQuwate+AcOjqjSPhE7W-DAdb6X+mnZVB21rZbVyotLkb1OQ@mail.gmail.com> (raw)
In-Reply-To: <SA1PR19MB49595E7E55B85B21784C2EE5CADE2@SA1PR19MB4959.namprd19.prod.outlook.com>
References: <SA1PR19MB49595E7E55B85B21784C2EE5CADE2@SA1PR19MB4959.namprd19.prod.outlook.com>

On Thu, Jul 4, 2024 at 1:57 PM Vasu Nagendra <[email protected]> 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.

>


view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: JSONPath operator and escaping values in query
  In-Reply-To: <CAKFQuwate+AcOjqjSPhE7W-DAdb6X+mnZVB21rZbVyotLkb1OQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox