JSON.TOGGLE

Syntax
JSON.TOGGLE key path
Available in:
Redis Stack / JSON 2.0.0
Time complexity:
O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

Toggle a boolean value stored at path.

return

Array reply of Integer reply - for each path, the new value (0-false or 1-true), or Null reply element for JSON values matching the path which are not boolean.

Examples

redis> JSON.SET doc $ '{"bool": true}'
OK
redis> JSON.TOGGLE doc $.bool
1) (integer) 0
redis> JSON.GET doc $
"[{\"bool\":false}]"
redis> JSON.TOGGLE doc $.bool
1) (integer) 1
redis> JSON.GET doc $
"[{\"bool\":true}]"

Feedback

If you've found issues on this page, or have suggestions for improvement, please submit a request to merge or open an issue in the repository.