JSON.OBJLEN
Syntax
JSON.OBJLEN key [path]
- Available in:
- Redis Stack / 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
报告在key
中的path
处的JSON对象中的键的数量
必需的参数
key
是解析的关键。对于不存在的键返回null
。
可选参数
path
是JSONPath指定的。默认是根$
。对于不存在的路径返回null
。
返回
JSON.OBJLEN 返回一个整数数组,每个路径对应的值为对象中的键的数量,如果匹配的 JSON 值不是对象,则返回 nil
。
有关回复的更多信息,请参阅 Redis 序列化协议规范。
示例
redis> JSON.SET doc $ '{"a":[3], "nested": {"a": {"b":2, "c": 1}}}'
OK
redis> JSON.OBJLEN doc $..a
1) (nil)
2) (integer) 2
另请参阅
JSON.ARRINDEX
| JSON.ARRINSERT