Clear container values (arrays/objects) and set numeric values to `0`
[Examples](#examples)
## Required arguments
key
is key to parse.
## Optional arguments
path
is JSONPath to specify. Default is root `$`. Nonexisting paths are ignored.
## Return
JSON.CLEAR returns an integer reply specified as the number of values cleared.
For more information about replies, see [Redis serialization protocol specification](/docs/reference/protocol-spec).
{{% alert title="Note" color="warning" %}}
Already cleared values are ignored for empty containers and zero numbers.
{{% /alert %}}
## Examples
Clear container values and set numeric values to 0
Create a JSON document.
{{< highlight bash >}}
redis> JSON.SET doc $ '{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14}'
OK
{{< / highlight >}}
Clear all container values. This returns the number of objects with cleared values.
{{< highlight bash >}}
redis> JSON.CLEAR doc $.*
(integer) 4
{{< / highlight >}}
Get the updated document. Note that numeric values have been set to `0`.
{{< highlight bash >}}
redis> JSON.GET doc $
"[{\"obj\":{},\"arr\":[],\"str\":\"foo\",\"bool\":true,\"int\":0,\"float\":0}]"
{{< / highlight >}}
## See also
`JSON.ARRINDEX` | `JSON.ARRINSERT`
## Related topics
* [RedisJSON](/docs/stack/json)
* [Index and search JSON documents](/docs/stack/search/indexing_json)