I am trying to print a response based on the particular parameters. For that, I have the response from an API as below:
{
"ABC": {
"code": "ABC",
"isActive": "true",
"lastUpdatedBy": "username",
"execution": {
"status": "0",
},
"priority": "1"
},
"DEF": {
"code": "DEF",
"isActive": "true",
"lastUpdatedBy": "username",
"execution": {
"status": "1",
},
"priority": "1"
},
"GHI": {
"code": "GHI",
"isActive": "true",
"lastUpdatedBy": "username",
"execution": {
"status": "2",
},
"priority": "1"
},
"JKL": {
"code": "JKL",
"isActive": "true",
"lastUpdatedBy": "username",
"execution": {
"status": "0",
},
"priority": "1"
},
}
Here is the feature file that I am using to print that particular value:
Feature: Value extraction
Background:
* def all = [ABC,DEF,GHI,JKL]
Scenario: Extract response value
Given url
When method get
Then status 200
And def value = []
And eval for(var i=0;i<all.length;i++) {value.add(response['#(all[i])']["execution"]["status"]) }
And print value
I want to extract the value of all parameters whose status is "0".
print response["ABC"]["execution"]["status"]
The above line gives the result but I want to parameterise the ["ABC"] part Any help on this? Is there any other way I can achieve this or am I doing something wrong to achieve this particular edge case?