Compare json files online.
Problem statement:
How can I compare whether two JSON objects are equal using online
tool/website, disregarding the order of lists?
first_sample.json document:
{ "errors": [ {"error": "invalid", "field": "email"}, {"error": "required", "field": "name"} ], "success": false }
second_sample.json document:
{ "success": false, "errors": [ {"error": "required", "field": "name"}, {"error": "invalid", "field": "email"} ] }'first_sample.json' and 'second_sample.json' should compare equal, even though the order of the "errors" lists are different.
Solution
Step as below
Sort JSON screenshot as below
- Sort both ('first_sample.json' and 'second_sample.json') file using Json sort online tool/website. ( json-sorter)
- Comapre json file using online compare tool/website. (diffnow)
Sort JSON screenshot as below
Compare JSON screenshot as below
No comments:
Post a Comment