Test values and commit an HTTP patch atomically
05test compares JSON values without editing them. A failed operation means the patch is not successful; HTTP PATCH must not leave partial changes.
Change the test’s value to numeric42. The test passes without editing, and the all-successful HTTP patch commits count42.
Source for this drawing: RFC 6902 · Read RFC section 4.6 ↗
New to this? Start hereA quick picture + helpful background
First, agree how to read the message.
An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
Successful earlier operations do not make a failed HTTP PATCH partly successful.
- The test operation MUST contain value and succeeds only when the target has the same JSON type and is equal by the RFC’s rules. Numbers compare numerically; strings compare characters; arrays compare in order; object member ordering and insignificant whitespace do not matter. Number42 does not equal string"42".
- On a violated requirement or unsuccessful operation, JSON Patch evaluation SHOULD terminate and the entire patch SHALL NOT be deemed successful. HTTP PATCH adds the atomicity requirement from RFC5789§2: the server MUST apply all changes atomically and MUST NOT apply any if the whole patch fails.
- The failed HTTP example replaces count1 with42 in private working state, then tests for string"42". The stored resource stays count1. The last state is an alternative successful numeric42test, which permits committing42. HTTP error status selection depends on the failure; JSON Patch does not mandate one code for every error.
This is schematic server staging, not a required implementation architecture. HTTP headers use Content-Type: application/json-patch+json. For base-dependent patches, clients SHOULD use a conditional request such as If-Match (RFC5789§2); test alone is not authentication or authorization. Protect patch contents and enforce application permissions; the old-browser warning in RFC6902§7 is historical, not a current browser-share statistic.
Read the RFC section ↗