A little confusion about JSON Path

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: A little confusion about JSON Path
Date: 2019-10-16 12:03:06
Message-ID: 8dcb9b9d-4863-b7e9-c3dc-e4ab2d01e918@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Imre Samu 2019-10-16 12:26:19 Re: Regarding db dump with Fc taking very long time to completion
Previous Message Daniel Verite 2019-10-16 11:38:45 Re: Text search lexer's handling of hyphens and negatives