Given two Javascript objects ( A and B ), there is a way to generate a JSON patch, so when this patch is applied to A , will it change the properties of the object to object B ?
For example, given the hypothetical JSONPatch function (possibly a function of a similar name with one of the following), the generate_patch function is required.
patch = generate_patch(A, B) JSONPatch.apply(patch, A) # modifies A so that it has the same properties as B.
In this question, A and B are Javascript objects. The patch created by RFC6902 is JSON, which indicates an array of operations that, when applied to A this object will become B The generate_patch function should not return JSON, although, rather, you can return a Javascript object for efficiency, which will become RFC6902 JSON-patch when JSON.stringify is called on it.
The projects that I found on the topic:
json javascript json-patch
Brian M. hunt
source share