TECHNOLOGY

JSON Merge Patch and JSON Patch express different edits

In this article
THE QUICK TAKE

Choose the patch document format before constructing the payload, then verify the complete intended change under that format’s null, array and operation rules.

Identify the patch format before interpreting the body

A configuration API supports partial edits to an analysis source list. Sending an HTTP PATCH request does not by itself say whether the body is JSON Merge Patch or JSON Patch. The HTTP PATCH specification distinguishes the method from accepted patch-document formats and provides Accept-Patch for advertising support. Use the documented media type and semantics rather than infer a format from a familiar-looking JSON payload.

Read merge-patch null as member removal

The Merge Patch specification describes an object-shaped example of changes. A null-valued member requests removal from the target object; it is not an ordinary instruction to retain that member with a null value. This makes the format less suitable for applications that need null as meaningful stored data. Leaving a member out of the patch also differs from including it with null, because the omission does not request its removal.

Treat arrays according to the selected operation model

Merge Patch replaces an array as a whole value rather than editing selected elements inside it. JSON Patch instead represents a sequence of operations such as add, remove and replace, with target paths. When the intention is to remove a particular source-list entry, choose the format that expresses the intended edit. Do not send a shortened array under the assumption that every patch format interprets it as an element-level difference.

Preserve JSON Patch operation order

JSON Patch evaluates each operation against the result of its predecessor. Removing an array entry changes later positions, so operation order can change which source a later path addresses. A test operation can check the expected target value and fail evaluation when it does not match. Task contracts describe the final configuration; the patch document must express the transition to that configuration under its actual sequential rules.

Review complete application and failure

HTTP PATCH requires atomic application of the set of changes: failure must not leave a partially modified representation exposed as the result. Preserve the server’s actual outcome and inspect the intended resource state where needed. Tool observations distinguish format rejection, failed operation and completed update. This gives a concrete explanation of the edit without treating every JSON object as a merge document, every null as a stored value or every ordered operation list as interchangeable with an example-shaped replacement.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles