Skip to content
JSON

Merge Patch (RFC 7386)

Partially update JSON documents.

By EZ4Code Team
patchrfc7386merge

Code

// Original document:
{ "a": "b", "c": { "d": "e", "f": "g" } }

// Patch document:
{ "a": "z", "c": { "f": null } }

// Result after merge-patch:
{ "a": "z", "c": { "d": "e" } }

Explanation

Merge patch (RFC 7386) recursively merges objects: fields in the patch overwrite the target, and a null value deletes the corresponding key. It is simpler than JSON Patch but cannot patch array elements by index. It is the basis of HTTP PATCH with application/merge-patch+json.

More JSON Snippets