Want to verify all list from referjson
should be present in response json (response
).
referjson = [
{
a: 1,
b: 2,
c: 4,
tag: "test"
},
{
a: 3,
b: 5,
tag: "mock"
},
...
];
response = [
{
tag: "mock",
a: 3,
b: 5,
c: 0,
d: 0,
e: 0
},
{
tag: "test",
a: 1,
b: 2,
c: 4,
d: 0,
e: 0
},
{
tag: "mocktest",
a: 3,
b: 5,
c: 0,
d: 0,
e: 0
},
...
];
Kindly help me to check one by one all the list ie { a: 1, b: 2, c: 4, tag: "test" }
should be present in response
then check for {a: 3, b: 5, tag: "mock" }
and so on ..
function checkJSON(referjson, response) {
for (var i = 0; i < referjson.length; i++) {
if (response.contains(referjson[i])) {
print("**PASS");
}
else {
karate.log(x[i] + "-------------Fail");
}
}
}
My if
doesn't do it for me.