Requires datadiff.
Also useful with yaml2json
.
[:~] $ jsondiff <( echo '{"foo":"bar"}' ) <( echo '{"foo":"bar", "baz":"bap"}' )
--- a
+++ b
{
+u'baz': u'bap',
u'foo': u'bar',
}
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
## https://pypi.python.org/pypi/datadiff | |
import datadiff | |
import json | |
def main(src_a, src_b, depth=9): | |
with open(src_a) as ifp: | |
obj_a = json.load(ifp) | |
with open(src_b) as ifp: | |
obj_b = json.load(ifp) | |
if obj_a != obj_b: | |
print datadiff.diff(obj_a, obj_b) | |
if __name__ == "__main__": | |
import sys | |
main(*sys.argv[1:]) |