JSON.OBJLEN
Syntax
JSON.OBJLEN key [path]
- Available in:
- Redis Open Source / JSON 1.0.0
- Time complexity:
- O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key
- ACL categories:
-
@json,@read,@slow, - Compatibility:
- Redis Enterprise and Redis Cloud compatibility
Report the number of keys in the JSON object at path in key
Required arguments
key
is key to parse. Returns null for nonexistent keys.
Optional arguments
path
is JSONPath to specify. Default is root $. Returns null for nonexistant path.
Examples
redis> JSON.SET doc $ '{"a":[3], "nested": {"a": {"b":2, "c": 1}}}'
OK
redis> JSON.OBJLEN doc $..a
1) (nil)
2) (integer) 2Redis Enterprise and Redis Cloud compatibility
| Redis Enterprise |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Supported |
✅ Flexible & Annual ✅ Free & Fixed |
Return information
With $-based path argument: Array reply of integer replies or null replies, where each element is the number of keys in the object, or null if the matching value is not an object.
With .-based path argument: Integer reply representing the number of keys in the object, or null reply if the matching value is not an object.
See also
JSON.ARRINDEX | JSON.ARRINSERT