mardi 30 juin 2020

How to sort json files and compare?

I have two json files which are similar but in different order. So the tests are failing while comparing. Can anyone suggest how to sort the json files before comparing them.

I have two json files which are similar but in different order. So the tests are failing while comparing. Can anyone suggest how to sort the json files before comparing them. Thanks in advance.

JSON-1

    {
"RowHeaders":[
     [
            {
                "DimensionName": "Account",
                "Label": "1013ETL",
                "MemberId": "1203"
            },
            {
                "DimensionName": "Measures",
                "Label": "MTD",
                "MemberId": "MTD"
            },
            {
                "DimensionName": "Reporting",
                "Label": "Consolidated (CC)",
                "MemberId": "14"
            }
        ],
        
      [
            {
                "DimensionName": "Account",
                "Label": "2010ETL - A/P - Trade",
                "MemberId": "1210"
            },
            {
                "DimensionName": "Measures",
                "Label": "YTD",
                "MemberId": "YTD"
            },
            {
                "DimensionName": "Reporting",
                "Label": "Consolidated (CC)",
                "MemberId": "14"
            }
        ],

       [
            {
                "DimensionName": "Account",
                "Label": "3030ETL - Retained Earnings - Beginning of Year",
                "MemberId": "1221"
            },
            {
                "DimensionName": "Measures",
                "Label": "YTD",
                "MemberId": "YTD"
            },
            {
                "DimensionName": "Reporting",
                "Label": "Consolidated (CC)",
                "MemberId": "14"
            }
        ]
     ],
    "Status":"Success",
     "StatusMessage":""
    }

JSON-2

{
"RowHeaders":[
       [
            {
                "DimensionName": "Account",
                "Label": "1013ETL",
                "MemberId": "1203"
            },
            {
                "DimensionName": "Measures",
                "Label": "MTD",
                "MemberId": "MTD"
            },
            {
                "DimensionName": "Reporting",
                "Label": "Consolidated (CC)",
                "MemberId": "14"
            }
        ],
        
        [
            {
                "DimensionName": "Account",
                "Label": "3030ETL - Retained Earnings - Beginning of Year",
                "MemberId": "1221"
            },
            {
                "DimensionName": "Measures",
                "Label": "YTD",
                "MemberId": "YTD"
            },
            {
                "DimensionName": "Reporting",
                "Label": "Consolidated (CC)",
                "MemberId": "14"
            }
        ],
        
        [
            {
                "DimensionName": "Account",
                "Label": "2010ETL - A/P - Trade",
                "MemberId": "1210"
            },
            {
                "DimensionName": "Measures",
                "Label": "YTD",
                "MemberId": "YTD"
            },
            {
                "DimensionName": "Reporting",
                "Label": "Consolidated (CC)",
                "MemberId": "14"
            }
        ]
     ],
"Status":"Success",
 "StatusMessage":""
}

Aucun commentaire:

Enregistrer un commentaire