JSON.TOGGLE key [path]

Available in: Redis Stack

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.


[] 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 $