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

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

jsonb_each_text() was added in PostgreSQL 9.4.


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

To extract the value as jsonb, use jsonb_each().

Change history


Basic usage example for jsonb_each_text():

SELECT key, value, pg_typeof(value)                    
             FROM jsonb_each_text('{"a":"foo", "b":{"bar":"baz"}}');
 key |     value      | pg_typeof 
 a   | foo            | text
 b   | {"bar": "baz"} | text
(2 rows)


JSON, System function

See also

jsonb_each(), json_each_text()