json_each_text()

A function expanding the top-level JSON object into a set of key/value pairs

json_each_text() is a system function which expands the top-level JSON object into a set of key/value pairs, with the value returned as text.

json_each_text() was added in PostgreSQL 9.3.

Usage

json_each_text ( json ) → setof record ( key text, value text )

To extract the value as json, use json_each().

Change history

Examples

Basic usage example for json_each_text():

postgres=# SELECT key, value                    
             FROM json_each_text('{"a":"foo", "b":{"bar":"baz"}}');
 key |     value     
-----+---------------
 a   | foo
 b   | {"bar":"baz"}
(2 rows)

Categories

JSON, System function

See also

json_each(), jsonb_each_text()