Toggle a Boolean value stored at path
key
is key to modify.
path
is JSONPath to specify. Default is root $
.
JSON.TOGGLE returns an array of integer replies for each path, the new value (0
if false
or 1
if true
), or nil
for JSON values matching the path that are not Boolean.
For more information about replies, see Redis serialization protocol specification.
Toogle a Boolean value stored at path
Create a JSON document.
{{< highlight bash >}} redis> JSON.SET doc $ '{"bool": true}' OK {{< / highlight >}}
Toggle the Boolean value.
{{< highlight bash >}} redis> JSON.TOGGLE doc $.bool
- (integer) 0 {{< / highlight >}}
Get the updated document.
{{< highlight bash >}} redis> JSON.GET doc $ "[{"bool":false}]" {{< / highlight >}}
Toggle the Boolean value.
{{< highlight bash >}} redis> JSON.TOGGLE doc $.bool
- (integer) 1 {{< / highlight >}}
Get the updated document.
{{< highlight bash >}} redis> JSON.GET doc $ "[{"bool":true}]" {{< / highlight >}}
JSON.SET
| JSON.GET