Contents
jsonb_each()
A function expanding the top-level JSON object into a set of key/value pairs
jsonb_each()
is a system function is a system function which expands the top-level JSON object into a set of key/value pairs, with the value returned as jsonb
.
jsonb_each()
was added in PostgreSQL 9.4.
Usage
jsonb_each (json
) → setof record (key
text
,value
json
To extract the value as text
, use jsonb_each_text()
.
Change history
- PostgreSQL 9.4
- added (commit d9134d0a)
Examples
Basic usage example for jsonb_each()
:
postgres=# SELECT key, value, jsonb_typeof(value) FROM jsonb_each('{"a":"foo", "b":{"bar":"baz"}}'); key | value | jsonb_typeof -----+----------------+-------------- a | "foo" | string b | {"bar": "baz"} | object (2 rows)
References
- PostgreSQL documentation: JSON Processing Functions