Search This Blog

Tuesday, 2 June 2020

Best way to compare json files online

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
  1. Sort both ('first_sample.json' and 'second_sample.json') file using Json sort online tool/website. ( json-sorter)
  2. Comapre json file using online compare tool/website. (diffnow)


Sort JSON screenshot as below



Compare JSON screenshot as below


No comments:

Post a Comment

Elasticsearch - Nodes, clusters, and shards

Elastic Stack Video - Load your gun in short time.   Beginner's Crash Course to Ela...

Recent Post