我正在使用java,我可以将这些JSON字符串作为文本进行比较。但是,我想将这两个JSON字符串比作树。有谁可以帮助我?
{
"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"
}
和
{
"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"
}
非常感谢您的帮助。
答案 0 :(得分:0)
为什么不将它转换为JSONOBject然后获取Key:Value对来比较这两个json字符串。
JSONObject obj1=new JSONObject(json1);
JSONObject obj2=new JSONObject(json2);
//Compare obj1 and obj2