I have a test in postman where I can validate a string value in an array but only if I know the index in which it is returned. The problem I run into is the index in which the value is returned can be random.
This is what the json looks like that I'm validating.
{
"cart": [{
"offeringId": "1234",
"offeringName": "Test1",
"totalOfferingAmount": -15,
"offeringTypeQualifier": "Test",
"productTypeQualifier": "Product",
"quantity": -1,
"messages": [],
"autoAdd": false,
"autoAction": "removed",
"addedByProcessor": true,
"qualificationLevel": "FQ",
"qualificationDetails": []
}, {
"offeringId": "5678",
"offeringName": "Test2",
"totalOfferingAmount": -15,
"offeringTypeQualifier": "Test",
"productTypeQualifier": "Product",
"quantity": -1,
"messages": [],
"autoAdd": false,
"autoAction": "removed",
"addedByProcessor": true,
"qualificationLevel": "FQ",
"qualificationDetails": []
}],
"isCartValidForCheckout": true,
"_status": []
}
Here is my postman test
var data = JSON.parse(responseBody);
tests ["Verify offeringId"] = data.cart[0].offeringId === "1234"