Visual RFC.
ALL RFCs / RFC 6902
Read the RFC ↗
RFC 6902 / JSON PATCH

Apply operations in array order

01

A JSON Patch is an array of edit instructions. Each operation sees the result of the preceding one.

RFC 6902 · § 3EXAMPLE
4 / 4
Apply operations in array orderAn instruction array contains add n value1 with an ignored note and then replace n value2. The target begins empty, becomes n1 after operation0, then n2 after operation1. Active instruction marker advances in array order. Separate last state rejects unknown increment at an explicit stop gate; no result is delivered.Ordered instructions · each result feeds the next{"op":"increment","path":"/n","value":1}Operation-name checkarrivesunknown opERROR · no seventh operationExactly one op and path are required
04
Reject an unknown operation name.

Separate malformed example: increment is not one of the six operation names. It is an error, not a seventh operation.

Source for this drawing: RFC 6902 · Read RFC section 3 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
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.

Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

KEY POINT

Operation order matters; object member order does not.

  • Each operation object MUST have exactly one op and exactly one path. The op MUST be add, remove, replace, move, copy or test; any other operation value is an error. The path is a JSON Pointer string, an address inside the target value.
  • Apply operations sequentially in array order, using each result as the next target. Rearranging fields inside an operation object does not change its meaning. Fields not defined for that operation MUST be ignored, rather than interpreted as new instructions.
  • add, replace and test require a value member; move and copy require a from pointer. Duplicate op/path members violate the exactly-one rule. Do not rely on a JSON parser silently picking the desired duplicate.
DETAILS

The fictional two-operation patch first creates n, then replaces it. Unlike JSON Merge Patch (RFC7396), this is an ordered instruction array, not an object-shaped merge. The media type is application/json-patch+json; JSON Patch can also be used outside HTTP. Syntax alone grants no permission to edit.

Read the RFC section ↗

All chapters in RFC 6902

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗