How to compare data from an object

Hi there,

I would like to validate some objects & arrays from the response body.
The responseBody is something like this:
HolidayRightsResults": [
{
“NissNumber”: ,
“HolidayRights”: ,
“CalculationMessages”: [
{
“Timestamp”: ,
“NewEmployerNumber”:,
“EmployeeNumber”: ,
“Type”: ,
“Message”: ,
“Details”: ,
“Code”: ,
“Info”:
}
]
},
{
“NissNumber”: ,
“HolidayRights”: ,
“CalculationMessages”: [
{
“Timestamp”: ,
“NewEmployerNumber”:,
“EmployeeNumber”: ,
“Type”: ,
“Message”: ,
“Details”: ,
“Code”: ,
“Info”:
}
]
},
{
“NissNumber”: ,
“HolidayRights”: ,
“CalculationMessages”: [
{
“Timestamp”: ,
“NewEmployerNumber”:,
“EmployeeNumber”: ,
“Type”: ,
“Message”: ,
“Details”: ,
“Code”: ,
“Info”:
}
]
},

Now I want to validate if HolidayrightsResults.Nissnumber and HolidayRightsResults.CalculationMessages.Type from every array with an object in a variable with the same structure like the responsebody. But I dont want to check every returned value in the object.

It seems that what you are looking for is a schema validation.

This tutorial I have created a while back may help you get started.

I want to check the actuele values for Nissnumber, In this case I left the values out for privacy reasons.
Not the schema.

Hey Coxjeffrey,
I found a lot of ways to assert values from the response as part of this community showcase. You’d like to have a look at the 2 and 7 cases in this list - Community Showcase - Assertions on API Test scripts.

You could loop through the array and assert only the values that you’d like say Nissnumber.

Hope that helps!

1 Like