JSON.RESP (已弃用)
截至JSON版本2.6,此命令被视为已弃用。
Syntax
JSON.RESP key [path]
- Available in:
- Redis Stack / JSON 1.0.0
- Time complexity:
- O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key
返回Redis序列化协议规范形式的key
中的JSON
必需的参数
key
是解析的关键。
可选参数
path
指定JSONPath。默认为根 $
。此命令使用以下从JSON到RESP的映射:
- JSON
null
映射到批量字符串回复。 - JSON
false
和true
值映射到简单的字符串回复。 - JSON 数字根据类型映射到整数回复或批量字符串回复。
- JSON 字符串映射到批量字符串回复。
- JSON数组表示为一个数组回复,其中第一个元素是简单字符串回复
[
,后面跟着数组的元素。 - JSON对象被表示为一个数组回复,其中第一个元素是简单字符串回复
{
。每个后续条目表示一个键值对,作为一个大块字符串回复的两条目数组回复。
有关回复的更多信息,请参阅Redis序列化协议规范。
返回
JSON.RESP 返回一个数组回复,该回复被指定为JSON的RESP形式,详细内容请参见Redis序列化协议规范。
示例
Return an array of RESP details about a document
创建一个JSON文档。
redis> JSON.SET item:2 $ '{"name":"Wireless earbuds","description":"Wireless Bluetooth in-ear headphones","connection":{"wireless":true,"type":"Bluetooth"},"price":64.99,"stock":17,"colors":["black","white"], "max_level":[80, 100, 120]}'
OK
获取有关文档的所有RESP详细信息。
redis> JSON.RESP item:2
1) {
2) "name"
3) "Wireless earbuds"
4) "description"
5) "Wireless Bluetooth in-ear headphones"
6) "connection"
7) 1) {
2) "wireless"
3) true
4) "type"
5) "Bluetooth"
8) "price"
9) "64.989999999999995"
10) "stock"
11) (integer) 17
12) "colors"
13) 1) [
2) "black"
3) "white"
14) "max_level"
15) 1) [
2) (integer) 80
3) (integer) 100
4) (integer) 120