I want to compare two json responses.I need a way to compare the reponses by not only ignoring the order of child attributes but also the ordering of elements inside json array. For ex:
target response:
{
name:abc,
category:bbb
place:aaa,
arrayList:[
{
id:1,
description:blah blah,
count:3
},
{
id:2,
count:4,
description:blah blah
}
]
}
source response
{
name:abc,
place:aaa,
category:ccc
arrayList:[
{
id:2,
description:blah blah,
count:3
},
{
id:1,
count:3,
}
]
}
When I compare above two response i Should get a differenceList which has following differences
differenceList:[
{ result: mismatch,
targetPath: .category,
sourcePath: .category,
target: bbb,
source: cccc
},
{ result: attribute not found in source response,
targetpath: .arrayList[0].description,
target: blah blah,
source: null
},
{ result: Mismatch,
targetpath: .arrayList[1].count,
sourcepath: .arrayList[0].count,
target: 4,
source: 3
}
]
tried using json comparator it doesnt seem to work. Need a java code for this