$ show stefankoegl/python-json-patch
python-json-patch is a Python library implementing the JSON Patch format (RFC 6902) for applying operations like add, remove, replace, move, copy, and test to JSON documents. It includes a smart diff algorithm to generate minimal patches by comparing two JSON objects, and provides command-line utilities (jsondiff and jsonpatch) for file-based operations. The core logic resides in jsonpatch.py, which is self-contained aside from the jsonpointer dependency, and handles edge cases such as duplicate keys via a custom multidict function. The library supports Python 2.7 and 3.7+ (though its setup.py contains an version specifier error excluding 3.4-3.6).
The LLM identified 1 files worth highlighting for reuse:
Implements the JSON Patch RFC 6902 specification with all six operations (add, remove, replace, move, copy, test) and an optimized diff algorithm that minimizes patch size by leveraging move and replace operations. Handles JSON Pointer resolution via external jsonpointer dependency, manages duplicate keys in JSON objects through a custom multidict function, and includes comprehensive error handling for conflict scenarios. The module is self-contained, dependency-light, and easily extractable for reuse in other projects.