Visual RFC.
ALL RFCs / RFC 7396
Read the RFC ↗
RFC 7396 / JSON MERGE PATCH

Replace an entire array

03

An array in the patch is a replacement value, not a list of element edits or items to append.

RFC 7396 · § 2EXAMPLE
3 / 3
Replace an entire arrayAn object with tags red and blue receives a tags-green array patch. The whole tags array is replaced by green, while the unmentioned keep member remains 1.An array is replaced as one valueThis is not an element-by-element mergeTarget tags"red""blue"Unmentioned member: keep = 1Patch{"tags":["green"]}Result{"tags":["green"],"keep":1}No append and no retained old tag elementsThe container keeps its other unmentioned member
03
Replace tags, retain keep.

The entire old array is replaced. The unmentioned keep member remains 1.

Source for this drawing: RFC 7396 · Read RFC section 2 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
New to this? Start hereA quick picture + helpful background

A message needs an address.

Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.

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
Replacement array
The whole new array value, not a partial edit to the previous array.
Related RFCs and changes

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

KEY POINT

Provide the full replacement array when changing array content.

  • If a patch value is anything other than an object, that whole value replaces the corresponding target. Arrays use this rule: their elements are not recursively merged by index.
  • To change one item in an array using Merge Patch, send the desired replacement array. You cannot use this format to patch only selected array elements.
  • An array can replace an object or scalar, and a scalar can replace an array. The containing object still retains its other unmentioned members when the patch at that containing level is an object.
DETAILS

Example target: {"tags":["red","blue"],"keep":1}. Patch: {"tags":["green"]}. Result: {"tags":["green"],"keep":1}. Old tags are neither retained nor appended. A null inside a replacement array is ordinary array content; it is not an object-member deletion instruction.

Read the RFC section ↗

All chapters in RFC 7396

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 ↗