我有两个Json文件,我将其转换为HashMaps。我想计算两个HashMaps的差异,我使用的是Maps.difference,它给出了两个hashMaps的差异。 但我的Map可以包含嵌套映射,它可以包含另一个hashmap,arraylist等作为值。
例如:
地图1:
{"hello1": "world",
"stu": { "name": "harry", "age":11},
"details": { "loc": "abc", "city": "xyz",
"state": "pqr", "clg": {"name": "aaa", "st":"aa",
"country":"aaaa"}},
"value": {
"object_type_name": 1,
"version": 1.2,
"subVersion": [
{"present": true,
"name": "personal/album",
},
{....}
]},
"diff_val" : [1,2,3]
}
地图2:
{"hello1": "world",
"stu": { "name": "John", "age":12},
"details": { "loc": "abc", "city": "xyz",
"state": "pqr", "clg": {"name": "bb", "st":"aa",
"country":"aaaa"}},
"value": {
"object_type_name": 1,
"version": 1.2,
"subVersion": [
{"present": true,
"name": "personal/album",
},
{....}
]},
"diff_val" : [1,2,3]
}
我想计算这两个HashMaps的差异,这样diff会显示确切的路径和值,其中差别是:
输出示例:
key diff value
-----------------------
stu/name: (harry, John)
stu/age: (11, 12)
details/clg/name: (aaa, bb)
......