I have the following JSON structure
{
"name": "xyz",
"address": {
"street": "avenida",
"number": "41414-44141",
"code": "33ll",
"moreFields": "some data"
},
"moreFields": "some data"
}
In my JUNIT class I will have to compare two JSON files which have the above structure. However I would like to ignore fields address.number
and address.code
. I understand I can use below code to ignore one field, but how can I change this to adopt to my requirements?
assertEquals(json1, json2,
return new CustomComparator(JSONCompareMode.NON_EXTENSIBLE,
Customization.customization("address.code",
(o1, o2) -> {
return true;
})
));
Looking at the implementation it appears the regex we provide to the customization method is modified and I am unable to comeup with the value for path
parameter which can a OR
condition.
Any suggestions are much appreciated
Thanks!