Usage
Arguments
The key containing the JSON document
JSONPath expression pointing to the object whose keys to retrieve. If omitted, defaults to the root path
$.Response
An array containing arrays of object keys for each matching path. Returns
null for paths that don’t exist or aren’t objects.Examples
Get keys from root object
Get keys with explicit path
Get keys from nested object
Get keys from multiple objects (wildcard path)
Check object structure
Iterate over object keys
Get keys from deeply nested objects
Handle non-existent paths
Handle non-object values
Get keys from array of objects
JSONPath Syntax
$- Get keys from root object$.object- Get keys from a nested object$.nested.object- Get keys from deeply nested object$..object- Get keys from all matching objects recursively$.array[*]- Get keys from objects within an array$.array[0]- Get keys from specific array element
Notes
- The path must point to a JSON object. Arrays, strings, numbers, and other non-object values return
null - The order of keys in the returned array may not match the insertion order
- When using wildcard paths, each matching object returns its own array of keys
- Returns an empty array
[]for empty objects{} - Returns
nullfor paths that don’t exist or don’t point to objects
See Also
- JSON.GET - Get JSON values
- JSON.SET - Set JSON values
- Redis JSON.OBJKEYS documentation