PostgreSQL 18 reference · JSON Functions

PostgreSQL #> and #>> JSON Path Operators

Read a nested JSON value by a path array: #> returns jsonb and #>> returns text, as in data #>> '{user,name}'.

PostgreSQL 18 Since 9.3

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

jsonb #> path  |  jsonb #>> path

Parameters

ParameterDescription
jsonb A jsonb (or json) value.
path A text array of keys and indexes, such as '{items,0,name}'.

Return value

jsonb or text.

Examples

Nested paths
SELECT '{"user":{"name":"Ada","langs":["en","fr"]}}'::jsonb #>> '{user,name}' AS name,
       '{"user":{"name":"Ada","langs":["en","fr"]}}'::jsonb #> '{user,langs}' AS langs;

Output

 name |    langs
------+--------------
 Ada  | ["en", "fr"]
(1 row)

Run this on your computer — see “Get Started” for setup.

Subscripts (14+)
SELECT ('{"a":{"b":[10,20]}}'::jsonb)['a']['b'][1] AS subscript;

Output

 subscript
-----------
 20
(1 row)

Run this on your computer — see “Get Started” for setup.

Version history

VersionChange
PostgreSQL 9.3Added
PostgreSQL 14jsonb values can also be read and updated with subscripts: data['a']['b'].

Was this page helpful?