Skip to content

Commit fafdca6

Browse files
authored
DEV: add RESP2/3 return information to the JSON commands (#1878)
1 parent bfb9d0b commit fafdca6

24 files changed

+405
-127
lines changed

content/commands/json.arrappend.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ To specify a string as an array value to append, wrap the quoted string with an
6363
{{% /alert %}}
6464
</details>
6565

66-
## Return value
67-
68-
`JSON.ARRAPPEND` returns an [array]({{< relref "develop/reference/protocol-spec#resp-arrays" >}}) of integer replies for each `path` match, the array's new length, or `nil`, if the matching JSON value is not an array.
69-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
70-
7166
## Examples
7267

7368
<details open>
@@ -96,6 +91,24 @@ redis> JSON.GET item:1 $.colors
9691

9792
</details>
9893

94+
## Return information
95+
96+
{{< multitabs id="json-arrappend-return-info"
97+
tab1="RESP2"
98+
tab2="RESP3" >}}
99+
100+
With `$`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array's new length, or `null` if the matching value is not an array.
101+
102+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array's new length, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
103+
104+
-tab-sep-
105+
106+
With `$`-based path argument (default): [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array's new length, or `null` if the matching value is not an array.
107+
108+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array's new length, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
109+
110+
{{< /multitabs >}}
111+
99112
## See also
100113

101114
[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})

content/commands/json.arrindex.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ is exclusive stop value to specify in a slice of the array to search, including
8989
Out-of-range indexes round to the array's start and end. An inverse index range (such as the range from 1 to 0) returns unfound or `-1`.
9090
{{% /alert %}}
9191

92-
## Return value
93-
94-
`JSON.ARRINDEX` returns an [array]({{< relref "develop/reference/protocol-spec#resp-arrays" >}}) of integer replies for each path, the first position in the array of each JSON value that matches the path, `-1` if unfound in the array, or `nil`, if the matching JSON value is not an array.
95-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
96-
9792
## Examples
9893

9994
<details open>
@@ -149,6 +144,24 @@ redis> JSON.ARRINDEX item:1 $..colors '"silver"'
149144
{{< / highlight >}}
150145
</details>
151146

147+
## Return information
148+
149+
{{< multitabs id="json-arrindex-return-info"
150+
tab1="RESP2"
151+
tab2="RESP3" >}}
152+
153+
With `$`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the first position in the array, `-1` if unfound, or `null` if the matching value is not an array.
154+
155+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the first position in the array, `-1` if unfound, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
156+
157+
-tab-sep-
158+
159+
With `$`-based path argument (default): [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the first position in the array, `-1` if unfound, or `null` if the matching value is not an array.
160+
161+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the first position in the array, `-1` if unfound, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
162+
163+
{{< /multitabs >}}
164+
152165
## See also
153166

154167
[`JSON.ARRAPPEND`]({{< relref "commands/json.arrappend/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})

content/commands/json.arrinsert.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ is position in the array where you want to insert a value. The index must be in
7171
is JSONPath to specify. Default is root `$`.
7272
</details>
7373

74-
## Return value
75-
76-
`JSON.ARRINSERT` returns an [array]({{< relref "develop/reference/protocol-spec#resp-arrays" >}}) of integer replies for each path, the array's new size, or `nil`, if the matching JSON value is not an array.
77-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
78-
7974
## Examples
8075

8176
<details open>
@@ -124,6 +119,24 @@ redis> JSON.GET item:1 $.colors
124119
{{< / highlight >}}
125120
</details>
126121

122+
## Return information
123+
124+
{{< multitabs id="json-arrinsert-return-info"
125+
tab1="RESP2"
126+
tab2="RESP3" >}}
127+
128+
With `$`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array's new size, or `null` if the matching value is not an array.
129+
130+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array's new size, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
131+
132+
-tab-sep-
133+
134+
With `$`-based path argument (default): [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array's new size, or `null` if the matching value is not an array.
135+
136+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array's new size, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
137+
138+
{{< /multitabs >}}
139+
127140
## See also
128141

129142
[`JSON.ARRAPPEND`]({{< relref "commands/json.arrappend/" >}}) | [`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}})

content/commands/json.arrlen.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ is key to parse.
5151
is JSONPath to specify. Default is root `$`, if not provided. Returns null if the `key` or `path` do not exist.
5252
</details>
5353

54-
## Return
55-
56-
`JSON.ARRLEN` returns an [array]({{< relref "develop/reference/protocol-spec#resp-arrays" >}}) of integer replies, an integer for each matching value, each is the array's length, or `nil`, if the matching value is not an array.
57-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
58-
5954
## Examples
6055

6156
<details open>
@@ -97,6 +92,24 @@ redis> JSON.GET item:2 '$..max_level'
9792

9893
</details>
9994

95+
## Return information
96+
97+
{{< multitabs id="json-arrlen-return-info"
98+
tab1="RESP2"
99+
tab2="RESP3" >}}
100+
101+
With `$`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array length, or `null` if the matching value is not an array.
102+
103+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array length, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
104+
105+
-tab-sep-
106+
107+
With `$`-based path argument (default): [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array length, or `null` if the matching value is not an array.
108+
109+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array length, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
110+
111+
{{< /multitabs >}}
112+
100113
## See also
101114

102115
[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})

content/commands/json.arrpop.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ is position in the array to start popping from. Default is `-1`, meaning the las
6565
is JSONPath to specify. Default is root `$`.
6666
</details>
6767

68-
## Return
69-
70-
`JSON.ARRPOP` returns an [array]({{< relref "develop/reference/protocol-spec#resp-arrays" >}}) of bulk string replies for each path, each reply is the popped JSON value, or `nil`, if the matching JSON value is not an array.
71-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
72-
7368
## Examples
7469

7570
<details open>
@@ -118,6 +113,20 @@ redis> JSON.GET key $.[1].max_level
118113
{{< / highlight >}}
119114
</details>
120115

116+
## Return information
117+
118+
{{< multitabs id="json-arrpop-return-info"
119+
tab1="RESP2"
120+
tab2="RESP3" >}}
121+
122+
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the popped JSON value as a string, or `null` if the matching value is not an array.
123+
124+
-tab-sep-
125+
126+
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the popped JSON value as a string, or `null` if the matching value is not an array.
127+
128+
{{< /multitabs >}}
129+
121130
## See also
122131

123132
[`JSON.ARRAPPEND`]({{< relref "commands/json.arrappend/" >}}) | [`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}})

content/commands/json.arrtrim.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ Behavior as of RedisJSON v2.0:
7878
* If `stop` is larger than the end of the array, it is treated like the last element.
7979
{{% /alert %}}
8080

81-
## Return
82-
83-
JSON.ARRTRIM returns an array of integer replies for each path, the array's new size, or `nil`, if the matching JSON value is not an array.
84-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
85-
8681
## Examples
8782

8883
<details open>
@@ -125,6 +120,24 @@ redis> JSON.GET key $.[1].max_level
125120
{{< / highlight >}}
126121
</details>
127122

123+
## Return information
124+
125+
{{< multitabs id="json-arrtrim-return-info"
126+
tab1="RESP2"
127+
tab2="RESP3" >}}
128+
129+
With `$`-based path argument: [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array's new size, or `null` if the matching value is not an array.
130+
131+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array's new size, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
132+
133+
-tab-sep-
134+
135+
With `$`-based path argument (default): [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) or [null replies]({{< relref "/develop/reference/protocol-spec#nulls" >}}), where each element is the array's new size, or `null` if the matching value is not an array.
136+
137+
With `.`-based path argument: [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the array's new size, or [null reply]({{< relref "/develop/reference/protocol-spec#nulls" >}}) if the matching value is not an array.
138+
139+
{{< /multitabs >}}
140+
128141
## See also
129142

130143
[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})

content/commands/json.clear.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ is key to parse.
5353
is JSONPath to specify. Default is root `$`. Nonexisting paths are ignored.
5454
</details>
5555

56-
## Return
57-
58-
JSON.CLEAR returns an integer reply specifying the number of matching JSON arrays and objects cleared + number of matching JSON numerical values zeroed.
59-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
60-
6156
{{% alert title="Note" color="warning" %}}
6257

6358
Already cleared values are ignored for empty containers and zero numbers.
@@ -91,6 +86,20 @@ redis> JSON.GET doc $
9186
{{< / highlight >}}
9287
</details>
9388

89+
## Return information
90+
91+
{{< multitabs id="json-clear-return-info"
92+
tab1="RESP2"
93+
tab2="RESP3" >}}
94+
95+
[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of matching JSON arrays and objects cleared plus the number of matching JSON numerical values zeroed.
96+
97+
-tab-sep-
98+
99+
[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of matching JSON arrays and objects cleared plus the number of matching JSON numerical values zeroed.
100+
101+
{{< /multitabs >}}
102+
94103
## See also
95104

96105
[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})

content/commands/json.debug-help.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,19 @@ title: JSON.DEBUG HELP
2424
---
2525
Return helpful information about the [`JSON.DEBUG`]({{< relref "commands/json.debug/" >}}) command
2626

27-
## Return
27+
## Return information
2828

29-
JSON.DEBUG HELP returns an array with helpful messages.
29+
{{< multitabs id="json-debug-help-return-info"
30+
tab1="RESP2"
31+
tab2="RESP3" >}}
32+
33+
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing helpful messages about the JSON.DEBUG command.
34+
35+
-tab-sep-
36+
37+
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing helpful messages about the JSON.DEBUG command.
38+
39+
{{< /multitabs >}}
3040

3141
## See also
3242

content/commands/json.debug-memory.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ is key to parse.
5555
is JSONPath to specify. Default is root `$`.
5656
</details>
5757

58-
## Return
59-
60-
JSON.DEBUG MEMORY returns an integer reply specified as the value size in bytes.
61-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
62-
6358
## Examples
6459

6560
<details open>
@@ -80,6 +75,20 @@ redis> JSON.DEBUG MEMORY item:2
8075
{{< / highlight >}}
8176
</details>
8277

78+
## Return information
79+
80+
{{< multitabs id="json-debug-memory-return-info"
81+
tab1="RESP2"
82+
tab2="RESP3" >}}
83+
84+
[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the value size in bytes.
85+
86+
-tab-sep-
87+
88+
[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the value size in bytes.
89+
90+
{{< /multitabs >}}
91+
8392
## See also
8493

8594
[`JSON.SET`]({{< relref "commands/json.set/" >}}) | [`JSON.ARRLEN`]({{< relref "commands/json.arrlen/" >}})

content/commands/json.del.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ Deleting an object's root is equivalent to deleting the key from Redis.
5858
{{% /alert %}}
5959
</details>
6060

61-
## Return
62-
63-
JSON.DEL returns an integer reply specified as the number of paths deleted (0 or more).
64-
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
65-
6661
## Examples
6762

6863
<details open>
@@ -90,6 +85,20 @@ redis> JSON.GET doc $
9085
{{< / highlight >}}
9186
</details>
9287

88+
## Return information
89+
90+
{{< multitabs id="json-del-return-info"
91+
tab1="RESP2"
92+
tab2="RESP3" >}}
93+
94+
[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of paths deleted (0 or more).
95+
96+
-tab-sep-
97+
98+
[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of paths deleted (0 or more).
99+
100+
{{< /multitabs >}}
101+
93102
## See also
94103

95104
[`JSON.SET`]({{< relref "commands/json.set/" >}}) | [`JSON.ARRLEN`]({{< relref "commands/json.arrlen/" >}})

0 commit comments

Comments
 (0)