def jsonString = '''{
"Content" : {
"2024-02-26" : {
"2222" : [
{
"Field1" : 101985,
"Field2" : "TYRE",
"Field3" : "2024-02-26T08:30:00",
"Field4" : "08:30",
"Field5" : "26 Feb 2024",
"Field6" : 1,
"Field7" : 60,
"Field8" : 6380,
"Field9" : 127,
"Field10" : "Past",
"Field11" : false,
"Field12" : 0,
"Field13" : null,
"Field14" : 2961655,
"Field15" : null,
"Field16" : null,
"Field17" : null
}
]
}
}
}'''
def json = new groovy.json.JsonSlurper().parseText(jsonString)
assert json.Content.'2024-02-26'.'2222'[0].Field1 == 101985
I swear that this is my last question on this, also i apologise for my stupidity.
What i need to do is compare the value of Field 1 to what is in Datasourcebook1, then if both are the same then return true, but if DatasourceBook1 is different return false.
it may be that i have to put 101985 into a variable then compare the 2 variables.
what i have.
def json = new groovy.json.JsonSlurper().parseText(jsonString)
assert json.Content.'2024-02-27'.'6380'[0].BranchCode == 101985
check = false;
if (json.contains == (datasourceBook1) ) {
check = true;
};
log.info "check=$check";