{"id":5642,"library":"json-delta","title":"JSON-delta","description":"JSON-delta is a multi-language software suite for computing deltas between JSON-serialized data structures and applying those deltas as patches. It aims to minimize communications overhead when manipulating data structures between separate programs. The Python implementation, currently at version 2.0.2, is considered the reference implementation, though it has seen limited development activity since its last release in October 2020.","status":"maintenance","version":"2.0.2","language":"en","source_language":"en","source_url":"https://json-delta.readthedocs.org/en/latest/","tags":["JSON","diff","patch","data synchronization","delta"],"install":[{"cmd":"pip install json-delta","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"Imports the function to compute the difference between two JSON structures.","symbol":"diff","correct":"from json_delta import diff"},{"note":"Imports the function to apply a computed diff to a JSON structure.","symbol":"patch","correct":"from json_delta import patch"}],"quickstart":{"code":"from json_delta import diff, patch\n\n# Original JSON-like data structure\na = {\n    \"name\": \"John Doe\",\n    \"age\": 30,\n    \"address\": {\n        \"street\": \"123 Main St\",\n        \"city\": \"Anytown\"\n    },\n    \"hobbies\": [\"reading\", \"hiking\"]\n}\n\n# Modified JSON-like data structure\nb = {\n    \"name\": \"Jane Doe\",\n    \"age\": 31,\n    \"address\": {\n        \"street\": \"456 Oak Ave\",\n        \"city\": \"Otherville\"\n    },\n    \"hobbies\": [\"reading\", \"coding\", \"swimming\"]\n}\n\n# Compute the diff\ndelta = diff(a, b)\nprint(f\"Computed Delta: {delta}\")\n\n# Apply the patch to 'a' to get 'b_reconstructed'\nb_reconstructed = patch(a, delta)\nprint(f\"Reconstructed B: {b_reconstructed}\")\n\nassert b == b_reconstructed\nprint(\"Original 'b' and reconstructed 'b' are equal.\")","lang":"python","description":"This quickstart demonstrates how to compute the difference (delta) between two Python dictionaries representing JSON structures and then apply that delta to the original structure to reconstruct the modified one."},"warnings":[{"fix":"Assess the project's long-term viability for your application. Consider contributing to its maintenance or evaluating alternative, more actively maintained JSON diffing libraries if long-term support is critical.","message":"The `json-delta` project has shown limited activity since its last release in October 2020. This indicates that it may not be actively maintained, which could lead to unaddressed bugs, security vulnerabilities, or lack of support for newer Python versions or features.","severity":"gotcha","affected_versions":"2.0.2 and potentially earlier versions still in use."},{"fix":"Familiarize yourself with the `json-delta` specific diff format as documented. If interoperability with RFC 6902 is required, consider using libraries explicitly designed for JSON Patch.","message":"The diff format generated by `json-delta` is a custom sequence of 'stanzas' (e.g., `[[key_path], update_value]`) and is not directly compatible with standard JSON Patch (RFC 6902). Users expecting an RFC 6902 compliant format will need to implement a conversion layer or choose a different library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If full reversibility (the ability to 'unpatch' to the exact original state) is required, ensure that deleted data is stored or retrieved through other means, or consider a library that explicitly supports reversible diff formats.","message":"When `diff` generates a deletion stanza (i.e., a stanza without an `update` value), the `patch` function cannot reconstruct the original deleted content if it's later needed for 'unpatching' or auditing. This means some diffs are not fully reversible without external knowledge of the deleted data.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Prefer using the more specific parameters (`array_align`, `compare_lengths`, `common_key_threshold`) directly to control diff behavior, rather than relying on the `minimal` parameter, especially if fine-grained control is needed.","message":"The `diff` function's `minimal` and `verbose` parameters are primarily for backward compatibility and can be superseded by more specific parameters like `array_align`, `compare_lengths`, and `common_key_threshold`. Using `minimal` in conjunction with these specific parameters might lead to unexpected behavior or warnings if `verbose` is also enabled.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}