Package com.github.fge.jsonpatch.mergepatch

JSON Merge Patch implementation

See:
          Description

Class Summary
JsonMergePatch Implementation of JSON Merge Patch (RFC 7386)
 

Package com.github.fge.jsonpatch.mergepatch Description

JSON Merge Patch implementation

This is a complete implementation of RFC 7386 (JSON Merge Patch).

You may want to use this instead of a "pure" (aka RFC 6902) JSON Patch if you want to do simple patching of JSON Objects, where this implementation really shines. For instance, if you want to replace a value for one property p with JSON String "bar", a JSON Patch will read:

     [
         { "op": "replace", "path": "/p", "value": "bar" }
     ]
 

whereas the equivalent JSON Merge Patch will be:

     { "p": "bar"}
 

Note that this is recursive; therefore, this:

     { "a": { "b": "c" } }
 

will replace (or add, if not present) the value at JSON Pointer /a/b with JSON String "c".

HOWEVER: while this seems attractive, there are a few traps. One of them is that, when a value of an object member in a JSON Merge Patch is a JSON null, the target will see the equivalent member removed; there is no way to specify that a value should be set with a JSON null value (JSON Patch allows for this).

The RFC defines a pseudo code for how a JSON Merge Patch is applied; this function is replicated in the javadoc for JsonMergePatch, so you are encouraged to read the javadoc for this class, and the RFC itself.