Skip to main content
Use JSON.MERGE to merge a JSON value into a document at a path, following the JSON Merge Patch semantics of RFC 7386. Objects are merged recursively: keys in the patch replace or create the matching keys in the target, keys set to null delete them, and any value that is not an object, arrays included, replaces the target outright instead of being merged element by element. The parent must already exist: merging into a missing child of an existing object creates it, but intermediate levels are not built along the way, and a key that does not exist yet can only be created by merging at the root. This is the command for partial updates of an object, where JSON.SET would replace the whole branch: one call can change a few fields, delete another, and leave the rest of the document untouched.

Syntax

Arguments

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.
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.