JSON Diff
Produce a minimal deterministic RFC 6902-style add/remove/replace patch turning one JSON document into another.
Description
Compare two JSON documents and generate a deterministic add, remove, and replace patch.
When to use JSON Diff
- Compare before-and-after API responses
- Create a replayable change set for JSON fixtures
- Locate nested object and array differences with JSON Pointer paths
How the calculation works
Interpreting the result
`opCount` gives the patch length and `patch` contains compact JSON. An empty array means the parsed documents are structurally equal. The generated operations are deterministic and round-trip through the companion applier, but they are not guaranteed to be the globally shortest possible edit script.
Important limitations
- Array items are matched by position rather than by identity or key.
- Different object key order is ignored because JSON objects are compared structurally.
- The output uses only add, remove, and replace operations.
References
-
RFC 6902: JavaScript Object Notation (JSON) Patch — RFC Editor
-
RFC 6901: JavaScript Object Notation (JSON) Pointer — RFC Editor