From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: A little confusion about JSON Path
Date: Wed, 16 Oct 2019 14:03:06 +0200
Message-ID: <8dcb9b9d-4863-b7e9-c3dc-e4ab2d01e918@gmx.net> (raw)
Hello,
I don't understand why the following two JSON Path expressions aren't doing the same thing in Postgres 12:
with sample (data) as (
values
('{"k1": {"list":[1,2,3]}}'::jsonb)
)
select data,
jsonb_path_exists(data, '$.k1.list.type() ? (@ == "array")'), -- returns true as expected
jsonb_path_exists(data, '$.k1.list ? (@.type() == "array")') -- returns false - not expected
from sample;
Apparently "@.type()" returns something different then "$.k1.list.type()"
But maybe I simply don't understand how the @ is supposed to work.
Regards
Thomas
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: spam_eater@gmx.net
Subject: Re: A little confusion about JSON Path
In-Reply-To: <8dcb9b9d-4863-b7e9-c3dc-e4ab2d01e918@gmx.net>
References: <8dcb9b9d-4863-b7e9-c3dc-e4ab2d01e918@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox