A Go library for computing the diff between two JSON documents as a series of RFC6902 JSON Patch operations.
jsondiff is a Go library that computes the differences between two JSON documents and outputs them as a series of JSON Patch (RFC6902) operations. It solves the problem of generating precise, structured diffs for applications like Kubernetes Mutating Webhooks, where you need to describe changes to JSON resources in a standardized format.
Go developers working with JSON data who need to generate diffs for APIs, Kubernetes admission controllers, or any system requiring JSON Patch compliance.
Developers choose jsondiff for its RFC6902 compliance, performance optimizations, and rich feature set like factorization and invertible patches, which are essential for efficient and reliable patch generation in production environments.
Compute the diff between two JSON documents as a series of JSON Patch (RFC6902) operations
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates standard JSON Patch operations, ensuring interoperability with systems like Kubernetes Mutating Webhooks, as highlighted in the README's primary use case.
Offers factorization to convert removal/addition pairs into move/copy operations and rationalization to replace nested changes with single replace operations, reducing JSON footprint as demonstrated in examples.
Provides options like LCS for array diffing, Ignores for field exclusion via JSON pointers, and custom marshal/unmarshal functions, allowing fine-grained control over comparison logic.
Enables generation of patches preceded by test operations for reversibility, useful for audit or undo scenarios, though with limitations on copy operations as noted in the README.
Options like LCS and Ignores are marked as experimental in the README, risking breaking changes or revisions in future releases, which could affect production code.
Requires Go 1.21+ due to dependencies on hash/maphash and other features, limiting adoption in environments with older Go versions or legacy systems.
The README warns of pitfalls like optional fields in Go structs leading to incorrect patches, requiring extra care and raw JSON handling for reliable webhook responses.