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.


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.


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


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.