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

Resolve paths and existing parents

02

A path names the place to edit. Adding a missing leaf is allowed, but its containing object or array must already exist.

RFC 6902 · § 4.1EXAMPLE
4 / 4
Resolve paths and existing parentsFirst two states show a root object branching to a/b and its child ~name. Tokens a~1b and ~0name decode to those literal names; add changes1to2 at an existing member. Third state stops at missing parent before child creation. Fourth separately uses empty path to replace the entire root object with an array tea.The path selects a value inside the document{"op":"add","path":"","value":["tea"]}{"a/b":{"~name":1}}replace whole root["tea"]Empty path names the whole JSON value
04
Replace the entire root.

Separate example: add at path "" with value["tea"] replaces the whole target with that array.

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

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

Creating a member does not create missing ancestors.

  • JSON Pointer decodes ~1 to slash, then ~0 to tilde. Thus /a~1b/~0name selects the member ~name inside the object named a/b. JSON string escapes are decoded before pointer evaluation; path is not a URI-fragment string.
  • add MUST include value. At an existing object member it replaces the value; at a new member it creates the member. The parent object or array must exist. A missing parent is an error; add does not build an arbitrary ancestor tree.
  • The empty pointer string names the whole target document. add there makes value the entire document, even if its type changes. Root removal is not taught here: held erratum4787 proposes a restriction, but that proposal is not a published MUST NOT.
DETAILS

The hierarchy uses literal fictional member names. RFC6901§§3–5 defines the pointer notation; RFC6902 defines what add may do at the resulting location. No percent-decoding or dot-path interpretation is implied.

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 ↗