'How can we include only specific json fields for comparision in deepdiff pyhton?
Here, we have 2 JSON, I want to include only 'id' field for comparison, rest of the fields should be ignored.
j1 = {'MyList': [{'a': 1, 'b': 2, 'c': [{'id': '1'}]},
{'a': 1, 'b': 2, 'c': [{'id': '2'}]}], "j": "2222"}
j2 = {'MyList': [{'a': 1, 'b': 2, 'c': [{'id': '4'}]},
{'a': 1, 'b': 2, 'c': [{'id': '7'}]}], "j": "7777"}
Please suggest, How we can achieve this using DeepDiff.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|