Replace an entire array
03An array in the patch is a replacement value, not a list of element edits or items to append.
The entire old array is replaced. The unmentioned keep member remains 1.
Source for this drawing: RFC 7396 · Read RFC section 2 ↗
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.
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.
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 ↗