Skip to content

DEV: add RESP2/3 return information to the JSON commands #1878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions content/commands/json.arrappend.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ To specify a string as an array value to append, wrap the quoted string with an
{{% /alert %}}
</details>

## Return value

`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.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

## Examples

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

</details>

## Return information

{{< multitabs id="json-arrappend-return-info"
tab1="RESP2"
tab2="RESP3" >}}

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.

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.

-tab-sep-

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.

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.

{{< /multitabs >}}

## See also

[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})
Expand Down
23 changes: 18 additions & 5 deletions content/commands/json.arrindex.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ is exclusive stop value to specify in a slice of the array to search, including
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`.
{{% /alert %}}

## Return value

`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.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

## Examples

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

## Return information

{{< multitabs id="json-arrindex-return-info"
tab1="RESP2"
tab2="RESP3" >}}

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.

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.

-tab-sep-

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.

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.

{{< /multitabs >}}

## See also

[`JSON.ARRAPPEND`]({{< relref "commands/json.arrappend/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})
Expand Down
23 changes: 18 additions & 5 deletions content/commands/json.arrinsert.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ is position in the array where you want to insert a value. The index must be in
is JSONPath to specify. Default is root `$`.
</details>

## Return value

`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.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

## Examples

<details open>
Expand Down Expand Up @@ -124,6 +119,24 @@ redis> JSON.GET item:1 $.colors
{{< / highlight >}}
</details>

## Return information

{{< multitabs id="json-arrinsert-return-info"
tab1="RESP2"
tab2="RESP3" >}}

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.

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.

-tab-sep-

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.

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.

{{< /multitabs >}}

## See also

[`JSON.ARRAPPEND`]({{< relref "commands/json.arrappend/" >}}) | [`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}})
Expand Down
23 changes: 18 additions & 5 deletions content/commands/json.arrlen.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ is key to parse.
is JSONPath to specify. Default is root `$`, if not provided. Returns null if the `key` or `path` do not exist.
</details>

## Return

`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.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

## Examples

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

</details>

## Return information

{{< multitabs id="json-arrlen-return-info"
tab1="RESP2"
tab2="RESP3" >}}

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.

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.

-tab-sep-

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.

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.

{{< /multitabs >}}

## See also

[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})
Expand Down
19 changes: 14 additions & 5 deletions content/commands/json.arrpop.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ is position in the array to start popping from. Default is `-1`, meaning the las
is JSONPath to specify. Default is root `$`.
</details>

## Return

`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.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

## Examples

<details open>
Expand Down Expand Up @@ -118,6 +113,20 @@ redis> JSON.GET key $.[1].max_level
{{< / highlight >}}
</details>

## Return information

{{< multitabs id="json-arrpop-return-info"
tab1="RESP2"
tab2="RESP3" >}}

[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.

-tab-sep-

[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.

{{< /multitabs >}}

## See also

[`JSON.ARRAPPEND`]({{< relref "commands/json.arrappend/" >}}) | [`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}})
Expand Down
23 changes: 18 additions & 5 deletions content/commands/json.arrtrim.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ Behavior as of RedisJSON v2.0:
* If `stop` is larger than the end of the array, it is treated like the last element.
{{% /alert %}}

## Return

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.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

## Examples

<details open>
Expand Down Expand Up @@ -125,6 +120,24 @@ redis> JSON.GET key $.[1].max_level
{{< / highlight >}}
</details>

## Return information

{{< multitabs id="json-arrtrim-return-info"
tab1="RESP2"
tab2="RESP3" >}}

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.

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.

-tab-sep-

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.

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.

{{< /multitabs >}}

## See also

[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})
Expand Down
19 changes: 14 additions & 5 deletions content/commands/json.clear.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ is key to parse.
is JSONPath to specify. Default is root `$`. Nonexisting paths are ignored.
</details>

## Return

JSON.CLEAR returns an integer reply specifying the number of matching JSON arrays and objects cleared + number of matching JSON numerical values zeroed.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

{{% alert title="Note" color="warning" %}}

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

## Return information

{{< multitabs id="json-clear-return-info"
tab1="RESP2"
tab2="RESP3" >}}

[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.

-tab-sep-

[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.

{{< /multitabs >}}

## See also

[`JSON.ARRINDEX`]({{< relref "commands/json.arrindex/" >}}) | [`JSON.ARRINSERT`]({{< relref "commands/json.arrinsert/" >}})
Expand Down
14 changes: 12 additions & 2 deletions content/commands/json.debug-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ title: JSON.DEBUG HELP
---
Return helpful information about the [`JSON.DEBUG`]({{< relref "commands/json.debug/" >}}) command

## Return
## Return information

JSON.DEBUG HELP returns an array with helpful messages.
{{< multitabs id="json-debug-help-return-info"
tab1="RESP2"
tab2="RESP3" >}}

[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.

-tab-sep-

[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.

{{< /multitabs >}}

## See also

Expand Down
19 changes: 14 additions & 5 deletions content/commands/json.debug-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ is key to parse.
is JSONPath to specify. Default is root `$`.
</details>

## Return

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

## Examples

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

## Return information

{{< multitabs id="json-debug-memory-return-info"
tab1="RESP2"
tab2="RESP3" >}}

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the value size in bytes.

-tab-sep-

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the value size in bytes.

{{< /multitabs >}}

## See also

[`JSON.SET`]({{< relref "commands/json.set/" >}}) | [`JSON.ARRLEN`]({{< relref "commands/json.arrlen/" >}})
Expand Down
19 changes: 14 additions & 5 deletions content/commands/json.del.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ Deleting an object's root is equivalent to deleting the key from Redis.
{{% /alert %}}
</details>

## Return

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

## Examples

<details open>
Expand Down Expand Up @@ -90,6 +85,20 @@ redis> JSON.GET doc $
{{< / highlight >}}
</details>

## Return information

{{< multitabs id="json-del-return-info"
tab1="RESP2"
tab2="RESP3" >}}

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of paths deleted (0 or more).

-tab-sep-

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of paths deleted (0 or more).

{{< /multitabs >}}

## See also

[`JSON.SET`]({{< relref "commands/json.set/" >}}) | [`JSON.ARRLEN`]({{< relref "commands/json.arrlen/" >}})
Expand Down
28 changes: 20 additions & 8 deletions content/commands/json.get.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ redis> JSON.GET myjsonkey INDENT "\t" NEWLINE "\n" SPACE " " path.to.value[1]

{{% /alert %}}

## Return

JSON.GET returns a bulk string representing a JSON array of string replies.
Each string is the JSON serialization of each JSON value that matches a path.
Using multiple paths, JSON.GET returns a bulk string representing a JSON object with string values.
Each string value is an array of the JSON serialization of each JSON value that matches a path.
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).

## Examples

<details open>
Expand Down Expand Up @@ -139,6 +131,26 @@ redis> JSON.GET doc ..a $..b
{{< / highlight >}}
</details>

## Return information

{{< multitabs id="json-get-return-info"
tab1="RESP2"
tab2="RESP3" >}}

[Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}): a JSON-encoded string representing the value(s) at the specified path(s).

With a single path, returns the JSON serialization of the value at that path.
With multiple paths, returns a JSON object where each key is a path and each value is an array of JSON serializations.

-tab-sep-

[Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}): a JSON-encoded string with a top-level array containing the value(s) at the specified path(s).

With a single path using `$` (default in RESP3), returns a JSON array containing the serialized value.
With multiple paths, returns a JSON object where each key is a path and each value is an array of JSON serializations.

{{< /multitabs >}}

## See also

[`JSON.SET`]({{< relref "commands/json.set/" >}}) | [`JSON.MGET`]({{< relref "commands/json.mget/" >}})
Expand Down
Loading