diff --git a/content/commands/json.set/index.md b/content/commands/json.set/index.md index d78d4c5d0f..1b89a9993d 100644 --- a/content/commands/json.set/index.md +++ b/content/commands/json.set/index.md @@ -79,7 +79,13 @@ sets the key only if it already exists. ## Return value -JSET.SET returns a simple string reply: `OK` if executed correctly or `nil` if the specified `NX` or `XX` conditions were not met. +Returns one of these replies: +- A simple string reply: `OK` if executed correctly +- `nil` + - if `key` exists but `path` does not exist and cannot be created + - if an `NX` or `XX` condition is unmet +- error if `key` does not exist and `path` is not root (`.` or `$`) + For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}). ## Examples @@ -123,6 +129,38 @@ redis> JSON.GET doc {{< / highlight >}} +
+path does not exist and cannot be created + +{{< highlight bash >}} +redis> JSON.SET doc $ 1 +OK +redis> JSON.SET doc $.x.y 2 +(nil) +{{< / highlight >}} +
+ +
+XX condition unmet + +{{< highlight bash >}} +redis> JSON.SET nonexistentkey $ 5 XX +(nil) +redis> JSON.GET nonexistentkey +(nil) +{{< / highlight >}} +
+ +
+key does not exist and path is not root + +{{< highlight bash >}} +redis> JSON.SET nonexistentkey $.x 5 +(error) ERR new objects must be created at the root +{{< / highlight >}} +
+ + ## See also [`JSON.GET`]({{< baseurl >}}/commands/json.get/) | [`JSON.MGET`]({{< baseurl >}}/commands/json.mget/)