I am trying to write a logic to see if value exists in json variable.
logic I wrote is considering state object as well but logic should only be checking in request object in input
We should not return true if we have businessCode in state object. Any help would be greatly appreciated. Here is the logic I have written and need some help in solving this.
var result = x.jsonPath("$..configurations[?(@.businessCode == 'Needed Object')].businessCode");
if (result != null && result.elementList().length > 0) {
IsNeeded = true;
}
Here is my input
{
"state": {
"PriceResult": {
"products": [
{
"configurations": [
{
"businessCode": "Needed object",
"configurations": []
}
]
}
]
}
},
"request": {
"body": [
{
"products": [
{
"configurations": [
{
"listPrice": 29.99,
"businessCode": "Needed object"
}
],
"id": "271811"
}
],
"id": "1022501"
},
{
"products": [
{
"configurations": [
{
"listPrice": 29.99,
"businessCode": "NOT Needed"
}
],
"id": "22222"
}
],
"id": "1111111"
}
]
}
}