json_object_keys()

A function returning the set of keys in the top-level JSON object

json_object_keys() is a system function returning the set of keys in the top-level JSON object.

json_object_keys() was added in PostgreSQL 9.3.

Usage

json_object_keys ( json ) → setof text

Change history

Examples

Basic usage example for json_object_keys():

postgres=# SELECT json_object_keys(
             $$
               {"foo":
                 {"bar": "bip"},
                "bar":
                 {"bat": "bop", "baz": "zoo"}}
             $$
           );
 json_object_keys
------------------
 foo
 bar
(2 rows)

Categories

JSON, System function

See also

jsonb_object_keys()