jsonb_object_keys()

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

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

jsonb_object_keys() was added in PostgreSQL 9.4.

Usage

jsonb_object_keys ( json ) → setof text

The returned list contains one entry for each key, apparently in alphabetical order.

Change history

Examples

Basic usage example for jsonb_object_keys():

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

Categories

JSON, System function

See also

json_object_keys()