File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed
content/commands/json.set Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,13 @@ sets the key only if it already exists.
7979
8080## Return value
8181
82- JSET.SET returns a simple string reply: ` OK ` if executed correctly or ` nil ` if the specified ` NX ` or ` XX ` conditions were not met.
82+ Returns one of these replies:
83+ - A simple string reply: ` OK ` if executed correctly
84+ - ` nil `
85+ - if ` key ` exists but ` path ` does not exist and cannot be created
86+ - if an ` NX ` or ` XX ` condition is unmet
87+ - error if ` key ` does not exist and ` path ` is not root (` . ` or ` $ ` )
88+
8389For more information about replies, see [ Redis serialization protocol specification] ({{< relref "/develop/reference/protocol-spec" >}}).
8490
8591## Examples
@@ -123,6 +129,38 @@ redis> JSON.GET doc
123129{{< / highlight >}}
124130</details >
125131
132+ <details open >
133+ <summary ><b >path does not exist and cannot be created</b ></summary >
134+
135+ {{< highlight bash >}}
136+ redis> JSON.SET doc $ 1
137+ OK
138+ redis> JSON.SET doc $.x.y 2
139+ (nil)
140+ {{< / highlight >}}
141+ </details >
142+
143+ <details open >
144+ <summary ><b >XX condition unmet</b ></summary >
145+
146+ {{< highlight bash >}}
147+ redis> JSON.SET nonexistentkey $ 5 XX
148+ (nil)
149+ redis> JSON.GET nonexistentkey
150+ (nil)
151+ {{< / highlight >}}
152+ </details >
153+
154+ <details open >
155+ <summary ><b >key does not exist and path is not root</b ></summary >
156+
157+ {{< highlight bash >}}
158+ redis> JSON.SET nonexistentkey $.x 5
159+ (error) ERR new objects must be created at the root
160+ {{< / highlight >}}
161+ </details >
162+
163+
126164## See also
127165
128166[ ` JSON.GET ` ] ({{< baseurl >}}/commands/json.get/) | [ ` JSON.MGET ` ] ({{< baseurl >}}/commands/json.mget/)
You can’t perform that action at this time.
0 commit comments