How to read and assert random indexed values from the json response?
I got stuck with the below requirement where the response has the values that varies index order in different test environments.
All i'm looking is how to read these random indexed values into a dynamic array and assert. Thanks in advance for your help!
Requirement:
I need to assert
1. Valid card present or not ( from the list from properties, valid cards are VISA and MASTER)
2. Valid customer id present or not ( Form the list from properties)
Here is the json response ( Dynamic array of values where there is a chance to increasing the list)
Note:
* Response values are dynamic and not in the same order accross all test environments
* Few environments has Null values in the response.
Response begining:
[
{
"ServiceOption": {
"CustomerId": "789456",
"deliveryOption": "online"
},
"MaskedPhone": "****8903",
"RegistrationNumber": "123456",
"country": "USA",
"card": VISA,
},
{
"ServiceOption": {
"CustomerId": "654987"
"deliveryOption": "Pickup"
},
"MaskedPhone": "****8904",
"RegistrationNumber": "654321",
"country": "RUS"
"card": "MASTER"
},
{
"ServiceOption": {
"CustomerId": "59456",
"deliveryOption": "Home"
},
"MaskedPhone": "****3893",
"RegistrationNumber": "624456",
"country": "CHI"
"card": "ABC"
},
{
"ServiceOption": {
"CustomerId": "84987"
"deliveryOption": "express"
},
"MaskedPhone": "****4098",
"RegistrationNumber": "664991",
"country": "UK",
"card": "DEF",
},
]