Upstash Documentation

JSON.FORGET

Delete JSON values (alias of JSON.DEL).
2 min read

Use JSON.FORGET to delete the value at a path in a JSON document. It is an alias of JSON.DEL with identical behavior, kept for compatibility with clients and code that use the older name.

Without a path the entire key is deleted, and the reply is the number of values that were deleted, which is 0 when the path matched nothing.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
keyYesNoJSON document key.
pathNoNoPath to delete; omitting it deletes the whole key.

Important points#

  • Raw TCP examples pass JSON values as valid JSON text. Typed Upstash SDK helpers serialize native objects and values for you.
  • Paths beginning with $ use JSONPath and can match multiple values, so many JSON commands return an array of per-match results.

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Integer
RESP3Integer
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
upstash_redis
ioredis
node-redis
redis-py
go-redis
jedis
redis-rs