JSON Patch and Merge Patch Explained
2025-12-15#JSON#Patch#Standard
JSON Patch (RFC 6902)
Defines a sequence of operations to precisely control modifications.
[
{ "op": "replace", "path": "/baz", "value": "boo" },
{ "op": "add", "path": "/hello", "value": ["world"] },
{ "op": "remove", "path": "/foo" }
]
Features: Atomicity, supports move/copy, explicit semantics.
JSON Merge Patch (RFC 7396)
Resembles simple object merging, using null to indicate deletion.
{
"title": "Hello!",
"author": {
"familyName": null
},
"phoneNumber": "+01-123-456-7890"
}
Features: Simple syntax, no partial array updates (replacement only), cannot set value to null (if null means delete).
Selection Advice
- Simple Updates: Merge Patch suffices for most CRUD scenarios.
- Complex Operations: Use JSON Patch for array manipulation or precise control.
Summary
Choosing the right Patch standard simplifies API design while meeting different data update granularity needs.
Related articles
Working with Large JSON Files - A Practical Guide
Techniques and tools for handling JSON files that exceed memory limits or browser constraints.
JSON vs XML - Choosing the Right Format for Your Use Case
A comprehensive comparison of JSON and XML to help you make informed format decisions.
JSON Tools Ecosystem - A Comprehensive Overview
Explore the best tools, libraries, and utilities for working with JSON across different platforms and use cases.
JSON Security Best Practices - Protecting Your Applications
Essential security measures for handling JSON data safely and preventing common vulnerabilities.
Understanding JSON Schema - A Complete Guide
Learn how to define and validate JSON structure with JSON Schema, from basics to advanced features.
JSON Performance Optimization Techniques
Speed up JSON parsing, serialization, and processing with these proven optimization strategies.