I have two JSON objects of the same structure - an original and one which I want to compare it to. There is only one level of information (i.e nothing has any children).
I want to compare the two and remember which fields, if any, were different by storing the key in the secondDifferingFields ArrayList.
def secondDifferingFields = new ArrayList()
orignialJSON.each {
print "original:"+it.value+":VS:"+secondJSON.it+":second"
if (it.value != secondJSON.it){
secondDifferingFields.add(it)
}
}
I can see that I am iterating through the values of the originalJSON, but am unsure on how to access the same key's value (if that's the right wording) in the secondJSON to be able to then compare them. With the print line I always see
original:XYZ:VS:null:second