Hacker News new | ask | show | jobs
by sonnyp 3681 days ago
I implemented/used both.

Here is a "live" playground https://json8.github.io/patch/demos/apply/ for JSON Patch

A few additional thoughts

JSON Patch can be pretty verbose but going around that is easy https://github.com/JSON8/patch#patch-size When possible I also compare the size of the patch (packed) and the expected document. If the expected document is smaller than the patch I use the PUT verb with the document as body otherwise PATCH verb with the patch as body.

Even though the spec doesn't talk about it at all, JSON Patch have the nice effect of being completely reversible (if you have the context) https://github.com/JSON8/patch#buildrevertpatch , not true for JSON Merge Patch

JSON Merge Patch patches can be translated to JSON Patch easily https://github.com/JSON8/merge-patch#tojsonpatch

https://github.com/JSON8/patch

https://github.com/JSON8/merge-patch

There is also https://github.com/ottypes/json0 which looks interesting and support more operations and string patches.