A function hash_json(data)
, accepting a structure loaded from json.load()
and computing a hash.
$ ./hashjson.py
Hash a.json: 8212462b8e9ce805cac2f0758127c5cfd7710baf
Hash b.json: 8212462b8e9ce805cac2f0758127c5cfd7710baf
JSON files a.json
and b.json
are loaded via load_json()
and structures passed to hash_json()
.
I was looking for these exactly.
But I noticed a problem.
If you have for example a dict with 1 entry with key and value being the same string
and a list with 2 items that has that same string, both will return the same hash.
This could be solved by appending an arbitrary character before hashing a list to create a difference.