Compare response to table values
I have a response(i have multiple such entries copied only one.) like below and I have a table that I need to compare it against.
{
"Items": [
{
"EmployeeId": "1",
"CompanyId": "1",
"FirstName": "SPENCER",
"LastName": "LIN"
"Status": {
"Code": "A",
"Description": "Active"
},
"BenefitClass": null,
"SupervisorId": null,
"SupervisorFirstName": null,
"SupervisorLastName": null,
"CostCenters": [
{
"Code": "01",
"Description": "Corporate"
}
]
}
I was able to print the results of the value in DB, like below:
/*****************************************this is the employeeId returned from DB.**************************************/
def returntripDB = getEmployeeFromDB(db,jsonRes)
returned DB value[[Id:1], [Id:113], [Id:129], [Id:130], [Id:131], [Id:134], [Id:136], [Id:140], [Id:143]]
public def getEmployeeFromDB(def database,jsonRes)
{
def query = "SELECT Id FROM [mydb].[mydb].[etable] order by etableid asc"
// log.info "QUERY for all employee id only "+query
return database.rows(query)
}
I want to iterate through the reponse and compare the values to the DB. How can i do this?
- Looks like your case is similar except that data is in json instead of xml
http://stackoverflow.com/questions/31472381/dynamically-compare-rest-xml-json-response-and-jdbc-using-groovy-array-in-soapui/35706976#35706976
and some links to process json provided in below thread, see Message 5
http://community.smartbear.com/t5/SoapUI-Open-Source/Extracting-data-from-CData-in-SOAP-Response/m-p/115898#U115898
Hope these links helps.