Skip to content

Instantly share code, notes, and snippets.

@bebound
Last active October 29, 2018 08:30
Show Gist options
  • Save bebound/f195b9b3ede4d84c350f7492ac5d74f1 to your computer and use it in GitHub Desktop.
Save bebound/f195b9b3ede4d84c350f7492ac5d74f1 to your computer and use it in GitHub Desktop.
import json
with open('test.json') as f:
list1 = json.load(f)
with open('test2.json') as f:
list2 = json.load(f)
for index, (dict1, dict2) in enumerate(zip(list1, list2)):
for (top_level_key1, top_level_value1), (top_level_key2, top_level_value2) in zip(dict1.items(), dict2.items()):
if top_level_value1 and top_level_value2:
for key in top_level_value1:
if top_level_value1[key] != top_level_value2[key] and key != 'server_time':
print('Found different value at dict{}, {} {} != {} {} '.format(index, key, top_level_value1[key],
key, top_level_value2[key]))
else:
if top_level_value1 != top_level_value2:
print('Found different dict{}, {}!={}'.format(index, top_level_value1, top_level_value2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment