​jsonb @@ jsonpath operator doc: ​Only the first item of the result is taken into account

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: ​jsonb @@ jsonpath operator doc: ​Only the first item of the result is taken into account
Date: 2023-04-01 06:02:47
Message-ID: CACJufxE01sxgvtG4QEvRZPzs_roggsZeVvBSGpjM5tzE5hMCLA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
https://www.postgresql.org/docs/current/functions-json.html

> jsonb @@ jsonpath → boolean
>
> Returns the result of a JSON path predicate check for the specified JSON
> value. Only the first item of the result is taken into account. If the
> result is not Boolean, then NULL is returned.
>
> '{"a":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2' → t
>

select jsonb_path_query('{"a":[1,2,3,4,5]}', '$.a[*]');
return

jsonb_path_query
> ------------------
> 1
> 2
> 3
> 4
> 5
> (5 rows)
>

I don't understand: "Only the first item of the result is taken into
account.".

Here, JSON path predicate check for the specified JSON value return true,
some return false. (1 > 2 is false, 2 > 2 is false).

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Phil Florent 2023-04-02 09:55:47 Support logical replication of DDLs
Previous Message Bryn Llewellyn 2023-03-31 21:53:14 Re: My tests show that a WITH HOLD cursor has subtly different semantics from a WITHOUT HOLD cursor