keys

Returns an array containing the list of keys in the top-most level of the input object.

Syntax

keys( <object> )

Arguments

<object>

The value for which you want the keys. The input value must be an object.

Returns

The function returns an ARRAY containing the keys.

Examples

Retrieve the keys from an object:

SELECT keys({"a": 1, "b": 2, "c": 3}) as keys;
+---------------+
| keys          |
+---------------+
| ['a','b','c'] |
+---------------+

Only the top-most level keys are returned:

SELECT keys(parse_json ('{"level_1_A": {"level_2": "two"},"level_1_B": "one"}')::object) AS keys;
+---------------------------+
| keys                      |
+---------------------------+
| ["level_1_A","level_1_B"] |
+---------------------------+