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

Copy values and move after removal

04

copy retains the source. move removes it first, then interprets its destination on the resulting document.

RFC 6902 · § 4.4EXAMPLE
5 / 5
Copy values and move after removalSeparate copy example leaves a tea and adds b tea. Then the RFC array move from1 to3 begins all,grass,cows,eat, removes grass leaving all,cows,eat and a held value, and inserts grass at post-removal index3. Final separate move from a to child a/b is stopped by the ancestor gate before any successful destination; a location cannot move into its descendant.Copy retains · move removes before adding{"op":"move","from":"/a","path":"/a/b"}/a/a/b childancestor checkMUST NOT move into your own descendantCompare pointer locations, not raw string prefixes
05
Stop an object moving into its child.

Separate invalid move from /a to /a/b: a is an ancestor of the proposed destination, so this move is forbidden.

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

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

A move’s destination uses the post-removal positions.

  • move and copy MUST contain a from pointer whose source exists. copy is equivalent to adding the source value at path; the source remains. The destination follows add rules, including the need for an existing parent.
  • move is equivalent to removing from, then immediately adding that removed value at path. In the same-array example, moving index1 to index3 removes grass first, then inserts it at index3 of the shortened array.
  • The from location MUST NOT be a proper prefix of path: an object cannot be moved into its own child. Compare pointer locations/tokens, not just raw string starts; /a and /ab are different member names. Missing sources and invalid destinations are errors.
DETAILS

The first state is a separate object-copy example. The next three reproduce the RFC A.7 array move; the final state is a separate invalid self-descendant move. These are not one continuous patch. Root-remove ambiguities are deliberately outside these examples.

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 ↗