You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Major bug when an iterable has both a change in an existing item AND adding/removing an additional item in the same key. The changed key would only show "root['root_key'][0]" rather than the nested key name "root['root_key'][0]['name']" and then therefore shows the WHOLE node as a change rather than individual keys that have changed. This is a major issue as it makes it difficult to identify what has changed in the nested key.
To Reproduce
import json
from deepdiff import DeepDiff
json1 ={
"id": 1234,
"name": "Rainbow Inc",
"employees": [
{
"name": "John Doe",
"role": "ceo"
}
],
}
json2 ={
"id": 1234,
"name": "Rainbow Inc",
"employees": [
{
"name": "Johnny Doe",
"role": "ceo"
},
{
"name": "James Doe",
"role": "cfo"
}
],
}
def checkForDifferences():
diff = DeepDiff(json2, json1, ignore_order=True, ignore_string_case=True, verbose_level=2)
# print("\n###diff=",diff)
# print("\n####diff.items()=",diff.items())
# Get added keys
added_keys = list(diff.get('dictionary_item_added', {}).keys()) #keys only
added_keys2 = diff.get('dictionary_item_added', []) #keys and values
added_iterable_keys = list(diff.get('iterable_item_added', {}).keys()) #keys only
added_iterable_keys2 = diff.get('iterable_item_added', []) #keys and values
# Get removed keys
removed_keys = list(diff.get('dictionary_item_removed', {}).keys()) #keys only
removed_keys2 = diff.get('dictionary_item_removed', []) #keys and values
removed_iterable_keys = list(diff.get('iterable_item_removed', {}).keys()) #keys only
removed_iterable_keys2 = diff.get('iterable_item_removed', []) #keys and values
# Get changed keys
changed_keys = list(diff.get('values_changed', {}).keys()) #keys only
changed_keys2 = diff.get('values_changed', []) #keys and values
print("\n###################################")
print("added_keys=",json.dumps(added_keys, indent=4))
print("added_keys2=",json.dumps(added_keys2, indent=4)) #keys with values
print("added_iterable_keys=",json.dumps(added_iterable_keys, indent=4))
print("added_iterable_keys2=",json.dumps(added_iterable_keys2, indent=4)) #keys with values
print("removed_keys=",json.dumps(removed_keys, indent=4))
print("removed_keys2=",json.dumps(removed_keys2, indent=4)) #keys with values
print("removed_iterable_keys=",json.dumps(removed_iterable_keys, indent=4))
print("removed_iterable_keys2=",json.dumps(removed_iterable_keys2, indent=4)) #keys with values
print("changed_keys=",json.dumps(changed_keys, indent=4)) #keys only
print("changed_keys2=",json.dumps(changed_keys2, indent=4)) #keys with values
checkForDifferences()
Expected behavior
The expected output should show the nested key "root['employees'][0]['name']" has changed rather than the whole node "root['employees'][0]".
OS, DeepDiff version and Python version (please complete the following information):
OS: Windows
Version 10
Python Version 3.13
DeepDiff Version 8.2.0
The text was updated successfully, but these errors were encountered:
Describe the bug
Major bug when an iterable has both a change in an existing item AND adding/removing an additional item in the same key. The changed key would only show "root['root_key'][0]" rather than the nested key name "root['root_key'][0]['name']" and then therefore shows the WHOLE node as a change rather than individual keys that have changed. This is a major issue as it makes it difficult to identify what has changed in the nested key.
To Reproduce
Expected behavior
The expected output should show the nested key "root['employees'][0]['name']" has changed rather than the whole node "root['employees'][0]".
OS, DeepDiff version and Python version (please complete the following information):
The text was updated successfully, but these errors were encountered: