Check the patch type first
04The type of the patch decides whether to merge object members or replace the whole target.
An object patch over a non-object target first discards that target. With no members to process, {} produces {}.
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
- Root patch
- The entire patch value, as distinct from a member value inside it.
- No-op
- An operation that makes no change; {} is only a no-op for object targets.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
An object patch and a non-object patch take different branches.
- The target may be any JSON value or may be undefined; the patch may be any JSON value. If the patch is not an object, the result is the entire patch, including a root null value.
- If the patch is an object but the target is not an object, start from an empty object and process the patch members. The previous scalar or array content is discarded.
- An empty object patch leaves an existing object unchanged, but it replaces a non-object target with an empty object. Therefore {} is not a universal no-op patch.
The drawing compares three independent examples, not three changes sent in sequence: a root null patch replaces an object with null; a string patch replaces an array with that string; an empty object patch converts an array target into {}. Root null is not the same operation as a null-valued member inside an object patch.
Read the RFC section ↗