JSON.TYPE
Syntax
JSON.TYPE 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
报告path
处JSON值的类型
必需的参数
key
是解析的关键。
可选参数
path
指定JSONPath。默认为根 $
。如果 key
或 path
不存在,则返回 null。
返回
JSON.TYPE 为每个路径返回一个字符串回复数组,指定为值的类型。 有关回复的更多信息,请参阅 Redis 序列化协议规范。
示例
redis> JSON.SET doc $ '{"a":2, "nested": {"a": true}, "foo": "bar"}'
OK
redis> JSON.TYPE doc $..foo
1) "string"
redis> JSON.TYPE doc $..a
1) "integer"
2) "boolean"
redis> JSON.TYPE doc $..dummy
(empty array)