JSON_KEYS()

All functions > JSON > JSON_KEYS()

Returns the keys of a JSON object as an array of strings.

Signatures

Returns: An array of the top-level keys in the object

JSON_KEYS(expr: JSON) → ARRAY(VARCHAR)
sql
ParameterTypeRequiredDescription
exprJSONYesA JSON expression that is an object

Notes

  • Returns the top-level keys of a JSON object
  • Key order depends on the backend and is not guaranteed
  • Returns NULL if the input is NULL
  • Returns NULL if the input is not a JSON object
  • Only returns top-level keys; nested object keys are not included
  • Use with JSON_EXTRACT to get keys of nested objects

See also

Examples

Edge cases

FeatureQL
SELECT
    f1 := JSON_KEYS(JSON_PARSE('{"name": "Alice", "age": 30}')), -- Get keys from a simple object
    f2 := JSON_KEYS(JSON_EXTRACT(JSON_PARSE('{"user": {"id": 1, "role": "admin"}}'), '$.user')) -- Get keys from a nested object
;
Result
f1 ARRAYf2 ARRAY
[name, age][id, role]

Last update at: 2026/05/26 17:22:09