JSON.DEL

Syntax

  1. JSON.DEL key [path]

Time complexity: O(N) when path is evaluated to a single value where N is the size of the deleted value, O(N) when path is evaluated to multiple values, where N is the size of the key

Delete a value

Examples

Required arguments

key

is key to modify.

Optional arguments

path

is JSONPath to specify. Default is root $. Nonexisting paths are ignored.

JSON.DEL - 图1Note

Deleting an object’s root is equivalent to deleting the key from Redis.

Return

JSON.DEL returns an integer reply specified as the number of paths deleted (0 or more). For more information about replies, see Redis serialization protocol specification.

Examples

Delete a value

Create a JSON document.

  1. 127.0.0.1:6379> JSON.SET doc $ '{"a": 1, "nested": {"a": 2, "b": 3}}'
  2. OK

Delete specified values.

  1. 127.0.0.1:6379> JSON.DEL doc $..a
  2. (integer) 2

Get the updated document.

  1. 127.0.0.1:6379> JSON.GET doc $
  2. "[{\"nested\":{\"b\":3}}]"

See also

JSON.SET | JSON.ARRLEN