QA
Intermediate LevelREST APIs & Web Services

Compare JSON Patch (RFC 6902) vs JSON Merge Patch (RFC 7396) for REST updates.

❓ Interview Prompt: Compare `PATCH` standards: JSON Patch (RFC 6902 array of atomic operations: `add`, `remove`, `replace`) vs JSON Merge Patch (RFC 7396 partial JSON object override).

RFC standards for executing partial updates via HTTP 'PATCH':

1
JSON Merge Patch (RFC 7396): 'Content-Type: application/merge-patch+json'.
•
Client sends partial JSON object overriding fields. Limitation: Cannot easily set a field to 'null' or remove an array element.
2
JSON Patch (RFC 6902): 'Content-Type: application/json-patch+json'.
•
Client sends an array of explicit atomic operations ('add', 'remove', 'replace', 'copy', 'move', 'test'). Allows precise manipulation of nested arrays!

Code Implementation Example

json
// JSON Patch (RFC 6902) explicit operation payload:
[
  { "op": "replace", "path": "/email", "value": "new@example.com" },
  { "op": "remove", "path": "/tags/0" },
  { "op": "test", "path": "/version", "value": 4 }
]
💡RFC 6902 JSON Patch atomic operations array payload.
🎯 Interview Key Takeaway

Use JSON Merge Patch for simple object field updates; use JSON Patch (RFC 6902) for atomic, array-specific mutations.

#JSON Patch#RFC 6902#PATCH#Intermediate
Back to all REST APIs & Web Services Questions→

More REST APIs & Web Services Interview Questions

Beginner LevelREST APIs & Web Services

What is HTTP Method Idempotency and how do you implement Idempotency Keys for REST APIs?

Beginner LevelREST APIs & Web Services

What are standard HTTP Status Codes (200, 201, 204, 400, 401, 403, 404, 409, 429, 500, 503)?

Beginner LevelREST APIs & Web Services

What are HTTP Verbs (GET, POST, PUT, PATCH, DELETE) and when to use PUT vs PATCH?