Re: 8.14.5 jsonb subscripting

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: arne(dot)sommerfelt(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: 8.14.5 jsonb subscripting
Date: 2024-04-09 11:16:51
Message-ID: e1b66e9d49654e1609107ac89b71c29be7c0014d.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Tue, 2024-04-09 at 09:31 +0000, PG Doc comments form wrote:
> Page: https://www.postgresql.org/docs/16/datatype-json.html
>
> Using subscripts with square brackets is not supported, one must use -> or
> #> operators
> The given examples result in error:
>
> SELECT ('{"a": 1}'::jsonb)['a'];
>
> -- Extract nested object value by key path
> SELECT ('{"a": {"b": {"c": 1}}}'::jsonb)['a']['b']['c'];
>
> -- Extract array element by index
> SELECT ('[1, "2", null]'::jsonb)[1];

You must be using an old PostgreSQL version where that is not yet supported.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Arne Sommerfelt 2024-04-09 13:05:57 Re: 8.14.5 jsonb subscripting
Previous Message Laurenz Albe 2024-04-09 10:36:08 Re: Postgres_FDW doc doesn't specify TYPE support in Remote Execution Options