API Design · Middle · Question 3 of 75
How should a JSON Merge Patch request treat null?
PATCH /users/42
Content-Type: application/merge-patch+json
{ "nickname": null, "city": "Kyiv" }- 1
nullsets every field to null - 2
nullis ignored - ✓Correct answer:
nullremoves the field (nickname), present fields are updated, missing fields stay unchanged
Explanation
Merge Patch (RFC 7396) can't set a value to literal null or edit array elements; JSON Patch (RFC 6902) can, with explicit operations.