JSON.DEL - Amazon ElastiCache (Redis OSS)
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

JSON.DEL

Deletes the JSON values at the path in a document key. If the path is the root, it is equivalent to deleting the key from Redis OSS.

Syntax

JSON.DEL <key> [path]
  • key (required) – A Redis OSS key of JSON document type.

  • path (optional) – A JSON path. Defaults to the root if not provided.

Return

  • Number of elements deleted.

  • 0 if the Redis OSS key does not exist.

  • 0 if the JSON path is invalid or does not exist.

Examples

Enhanced path syntax:

127.0.0.1:6379> JSON.SET k1 . '{"a":{}, "b":{"a":1}, "c":{"a":1, "b":2}, "d":{"a":1, "b":2, "c":3}, "e": [1,2,3,4,5]}' OK 127.0.0.1:6379> JSON.DEL k1 $.d.* (integer) 3 127.0.0.1:6379> JSOn.GET k1 "{\"a\":{},\"b\":{\"a\":1},\"c\":{\"a\":1,\"b\":2},\"d\":{},\"e\":[1,2,3,4,5]}" 127.0.0.1:6379> JSON.DEL k1 $.e[*] (integer) 5 127.0.0.1:6379> JSOn.GET k1 "{\"a\":{},\"b\":{\"a\":1},\"c\":{\"a\":1,\"b\":2},\"d\":{},\"e\":[]}"

Restricted path syntax:

127.0.0.1:6379> JSON.SET k1 . '{"a":{}, "b":{"a":1}, "c":{"a":1, "b":2}, "d":{"a":1, "b":2, "c":3}, "e": [1,2,3,4,5]}' OK 127.0.0.1:6379> JSON.DEL k1 .d.* (integer) 3 127.0.0.1:6379> JSON.GET k1 "{\"a\":{},\"b\":{\"a\":1},\"c\":{\"a\":1,\"b\":2},\"d\":{},\"e\":[1,2,3,4,5]}" 127.0.0.1:6379> JSON.DEL k1 .e[*] (integer) 5 127.0.0.1:6379> JSON.GET k1 "{\"a\":{},\"b\":{\"a\":1},\"c\":{\"a\":1,\"b\":2},\"d\":{},\"e\":[]}"