Skip to content

Latest commit

 

History

History
74 lines (47 loc) · 1.47 KB

json.toggle.md

File metadata and controls

74 lines (47 loc) · 1.47 KB

Toggle a Boolean value stored at path

Examples

Required arguments

key

is key to modify.

Optional arguments

path

is JSONPath to specify. Default is root $.

Return

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.

Examples

Toogle a Boolean value stored at path

Create a JSON document.

{{< highlight bash >}} 127.0.0.1:6379> JSON.SET doc $ '{"bool": true}' OK {{< / highlight >}}

Toggle the Boolean value.

{{< highlight bash >}} 127.0.0.1:6379> JSON.TOGGLE doc $.bool

  1. (integer) 0 {{< / highlight >}}

Get the updated document.

{{< highlight bash >}} 127.0.0.1:6379> JSON.GET doc $ "[{"bool":false}]" {{< / highlight >}}

Toggle the Boolean value.

{{< highlight bash >}} 127.0.0.1:6379> JSON.TOGGLE doc $.bool

  1. (integer) 1 {{< / highlight >}}

Get the updated document.

{{< highlight bash >}} 127.0.0.1:6379> JSON.GET doc $ "[{"bool":true}]" {{< / highlight >}}

See also

JSON.SET | JSON.GET

Related topics