Manipulate JSON documents using "JSON patch" format.
This software is available under the MIT License
This software gains inspration from json_tools and benjamin/jsondiffpatch
$ pip install git+https://github.com/apack1001/json-diff-patch.git
TBD
Just run nosetests from the repo root.
There are two ways of using json_diff_patch:
- As a CLI utilty.
- As a Python module.
After you've installed json_diff_patch you can access it via json command in the
shell. It provides a pretty simple yet powerful interface to manipulate JSON
documents:
-
print [input_file]Pretty-print a JSON file with syntax highlighting and keys sorting.
If
input_fileis omitted or equals-, reads JSON from STDIN.Example:
$ echo '{"Hello": ["w", "o", "r", "l", "d", "!"]}' | json print { "Hello": [ "w", "o", "r", "l", "d", "!" ] } -
diff [file1] [file2]Calculate difference between two JSON documents and output it in JSON patch format.
Either
file1orfile2can be set to-, in order to read JSON from STDIN.Example:
$ json diff doc1.json doc2.json [ { "add": "/lol", "value": "wut" }, { "remove": "/some/field", "prev": { "compound": "value" } } ] -
patch [options] input [patch [patch ...]]Modify the JSON file
inputusing a series of JSONpatches.If
patchis omitted or equals-, its content is read from STDIN.Options:
-i, --inplaceModify
source_fileinplace instead of printing it to STDOUT.
TBD
- Support more JSON patch options: currently json_diff_patch only supports add, remove and replace.
- Make diff output more human readable (not JSONish).
- Improve documentation.