JSONObject Comparison

I am using java and I can compare these JSON strings as text. However, I would like to compare these two JSON strings as tree. Could anyone help me?

{
    "cMillis": {
        "iLowerLimit": {
            "iOrdinal": 21,
            "iName": "secondOfMinute"
        }
    },
    "cSecond": {
        "iLowerLimit": {
            "iOrdinal": 21,
            "iName": "secondOfMinute"
        },
        "iUpperLimit": {
            "iOrdinal": 19,
            "iName": "minuteOfHour"
        }
    },
    "cMinute": {
        "iUpperLimit": {
            "iOrdinal": 17,
            "iName": "hourOfDay"
        }
    },
    "cHour": {
        "iLowerLimit": {
            "iOrdinal": 17,
            "iName": "hourOfDay"
        },
        "iUpperLimit": {
            "iOrdinal": 6,
            "iName": "dayOfYear"
        }
    },
    "cDayOfWeek": {
        "iLowerLimit": {
            "iOrdinal": 12,
            "iName": "dayOfWeek"
        },
        "iUpperLimit": {
            "iOrdinal": 11,
            "iName": "weekOfWeekyear"
        }
    },
    "cDayOfMonth": {
        "iLowerLimit": {
            "iOrdinal": 8,
            "iName": "dayOfMonth"
        },
        "iUpperLimit": {
            "iOrdinal": 7,
            "iName": "monthOfYear"
        }
    },
    "cDayOfYear": {
        "iLowerLimit": {
            "iOrdinal": 6,
            "iName": "dayOfYear"
        },
        "iUpperLimit": {
            "iOrdinal": 5,
            "iName": "year"
        }
    },
    "cWeekOfWeekyear": {
        "iLowerLimit": {
            "iOrdinal": 11,
            "iName": "weekOfWeekyear"
        },
        "iUpperLimit": {
            "iOrdinal": 10,
            "iName": "weekyear"
        }
    },
    "cWeekyear": {
        "iLowerLimit": {
            "iOrdinal": 10,
            "iName": "weekyear"
        }
    },
    "cMonth": {
        "iLowerLimit": {
            "iOrdinal": 7,
            "iName": "monthOfYear"
        },
        "iUpperLimit": {
            "iOrdinal": 5,
            "iName": "year"
        }
    },
    "cYear": {
        "iLowerLimit": {
            "iOrdinal": 5,
            "iName": "year"
        }
    },
    "cDate": {
        "iLowerLimit": {
            "iOrdinal": 6,
            "iName": "dayOfYear"
        }
    },
    "cTime": {
        "iUpperLimit": {
            "iOrdinal": 6,
            "iName": "dayOfYear"
        }
    },
    "fName": "testStaticGetTimeOnlyInstance"
}

And

{
    "cMillis": {
        "iUpperLimit": {
            "iOrdinal": 25,
            ”iName":"secondOfMinute"}},"cSecond":{"iLowerLimit":{"iOrdinal":25,”iName": "secondOfMinute"
        },
        "iUpperLimit": {
            "iOrdinal”:40,”iName": "minuteOfHour"
        }
    },
    "cMinute": {
        "iLowerLimit": {
            "iOrdinal": 19,
            "iName": "minuteOfHour"
        },
        "iUpperLimit": {
            "iOrdinal": 17,
            "iName": "hourOfDay"
        }
    },
    "cHour": {
        "iLowerLimit": {
            "iOrdinal": 17,
            "iName": "hourOfDay"
        },
        "iUpperLimit": {
            "iOrdinal": 6,
            "iName": "dayOfYear"
        }
    },
    "cDayOfWeek": {
        "iLowerLimit": {
            "iOrdinal": 12,
            "iName": "dayOfWeek"
        },
        "iUpperLimit": {
            "iOrdinal": 11,
            "iName": "weekOfWeekyear"
        }
    },
    "cDayOfMonth": {
        "iLowerLimit": {
            "iOrdinal": 8,
            "iName": "dayOfMonth"
        },
        "iUpperLimit": {
            "iOrdinal": 7,
            "iName": "monthOfYear"
        }
    },
    "cDayOfYear": {
        "iLowerLimit": {
            "iOrdinal": 6,
            "iName": "dayOfYear"
        },
        "iUpperLimit": {
            "iOrdinal": 5,
            "iName": "year"
        }
    },
    "cWeekOfWeekyear": {
        "iLowerLimit": {
            "iOrdinal": 11,
            "iName": "weekOfWeekyear"
        },
        "iUpperLimit": {
            "iOrdinal": 10,
            "iName": "weekyear"
        }
    },
    "cWeekyear": {
        "iLowerLimit": {
            "iOrdinal": 10,
            "iName": "weekyear"
        }
    },
    "cMonth": {
        "iLowerLimit": {
            "iOrdinal": 7,
            "iName": "monthOfYear"
        },
        "iUpperLimit": {
            "iOrdinal": 5,
            "iName": "year"
        }
    },
    "cYear": {
        "iLowerLimit": {
            "iOrdinal": 5,
            "iName": "year"
        }
    },
    "cDate": {
        "iLowerLimit": {
            "iOrdinal": 6,
            "iName": "dayOfMonth”}},”cTime": {
                "iUpperLimit": {
                    "iOrdinal": 6,
                    "iName": "dayOfYear"
                }
            },
            "fName": "testStaticGetTimeOnlyInstance"
        }

Greatly Appreciate your help.

Answers


Why dont you convert it to JSONOBject and then get the Key:Value pair to compare those two json strings.

JSONObject obj1=new JSONObject(json1);
JSONObject obj2=new JSONObject(json2);

//Compare obj1 and obj2 

Need Your Help

Group by major count

sql sql-server group-by

Greetings I have a question having sql like