Back to Redis

JSON.DEL

content/commands/json.del.md

latest1.9 KB
Original Source

Delete a value

Examples

Required arguments

<details open><summary><code>key</code></summary>

is key to modify.

</details>

Optional arguments

<details open><summary><code>path</code></summary>

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

{{% alert title="Note" color="warning" %}}

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

{{% /alert %}}

</details>

Examples

<details open> <summary><b>Delete a value</b></summary>

Create a JSON document.

{{< highlight bash >}} redis> JSON.SET doc $ '{"a": 1, "nested": {"a": 2, "b": 3}}' OK {{< / highlight >}}

Delete specified values.

{{< highlight bash >}} redis> JSON.DEL doc $..a (integer) 2 {{< / highlight >}}

Get the updated document.

{{< highlight bash >}} redis> JSON.GET doc $ "[{"nested":{"b":3}}]" {{< / highlight >}}

</details>

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Flexible & Annual</span> <span title="Supported">✅ Free & Fixed</nobr></span> | |

Return information

{{< multitabs id="json-del-return-info" tab1="RESP2" tab2="RESP3" >}}

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of paths deleted (0 or more).

-tab-sep-

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of paths deleted (0 or more).

{{< /multitabs >}}

See also

[JSON.SET]({{< relref "commands/json.set/" >}}) | [JSON.ARRLEN]({{< relref "commands/json.arrlen/" >}})

  • [RedisJSON]({{< relref "/develop/data-types/json/" >}})
  • [Index and search JSON documents]({{< relref "/develop/ai/search-and-query/indexing/" >}})