JSON Merge Patch
JSON Merge Patch (RFC 7396) updates a JSON document by merging a partial object into the existing resource. Present keys overwrite or recurse into nested objects, and null values remove keys. It is simpler than JSON Patch for many REST PATCH endpoints that only need shallow or nested field updates.
Technical Architecture & Deep-Dive
Merge Patch bodies look like ordinary JSON: { "name": "Updated", "settings": { "theme": "dark" } }. Servers merge settings deeply while replacing scalars at the top level. Sending null for a key deletes it, which is a common contract for optional metadata fields.
Because merge semantics can be ambiguous for arrays, APIs often document array replacement rules clearly. Edge gateways can accept Merge Patch from clients and translate to provider-specific PUT or PATCH formats, or apply merge results locally on cached read models.
Key Architectural Benefits
Implement JSON Merge Patch at the Edge
Deploy lightweight API aggregation, edge caching, and secret injection in minutes without Docker containers or complex servers.
Frequently Asked Questions
Q:When should I prefer JSON Patch over Merge Patch?
Choose JSON Patch when you need ordered ops, array inserts, move/copy, or test for version checks. Merge Patch fits simple field updates.
Related Architecture Concepts
JSON Patch is an RFC 6902 format that describes changes to a JSON document as an ordered array of operations, each with op, path, and optional value or from fields. Clients send compact patches instead of full resource bodies, which reduces bandwidth and supports optimistic concurrency on REST and sync APIs.
JSON Pointer is an RFC 6901 syntax for identifying a single value inside a JSON document using a slash-separated path string such as /user/addresses/0/city. Pointers are the addressing layer for JSON Patch, JSON Merge Patch tools, and field mask engines that need precise, portable paths into nested payloads.
Canonical JSON is a deterministic serialization of JSON objects where key order, whitespace, and number formatting follow fixed rules. Two logically equal objects produce identical byte strings, which is required for cryptographic signatures, webhook verification, and cache keys that must not change with pretty-printing.