As far as I can tell, all the test files use dictionaries as the top-level object. But JSON does not require this, and when I tried running it on a pair of files containing arrays, it crashed.
According to the spec, json
is made up of one element
, and an element
is made up of a value
optionally surrounded by whitespace. A value
is any of object
, array
, string
, number
, "true"
, "false"
, "null"
.
Give me the example test data failing, please.
Hmm, well, it's been ages since I filed this, but you can just generate one:
$ ipython3 In [1]: import json In [2]: with open('old.json', 'w') as f: json.dump([1, 2, 3], f) In [3]: with open('new.json', 'w') as f: json.dump([1, 3, 3], f)$ json_diff old.json new.json Traceback (most recent call last): File ".../bin/json_diff", line 10, in <module> sys.exit(main()) File ".../python3.7/site-packages/json_diff.py", line 370, in main diff_res = diff.compare_dicts() File ".../python3.7/site-packages/json_diff.py", line 305, in compare_dicts old_keys = set(old_obj.keys()) AttributeError: 'list' object has no attribute 'keys'
Same thing - this prevents me from using json-diff with the json I have.