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