JSON.CLEAR
Syntax
JSON.CLEAR key [path]
- Available in:
- Redis Stack / JSON 2.0.0
- Time complexity:
- O(N) when path is evaluated to a single value where N is the size of the values, O(N) when path is evaluated to multiple values, where N is the size of the key
Clears container values (Arrays/Objects), and sets numeric values to 0
.
Already cleared values are ignored: empty containers, and zero numbers.
path
defaults to root if not provided. Non-existing paths are ignored.
Return
Integer reply: specifically the number of values cleared.
Examples
redis> JSON.SET doc $ '{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14}'
OK
redis> JSON.CLEAR doc $.*
(integer) 4
redis> JSON.GET doc $
"[{\"obj\":{},\"arr\":[],\"str\":\"foo\",\"bool\":true,\"int\":0,\"float\":0}]"
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.