Hi is there's a way I can simulate this scenario using JSONPath? Example I have multiple City value and I want all to extract and put it on an Array. Your response is highly appreciated. Thank you so much.
[ { "id": "MAIN", "key": 1 }, { "city": "Roselle", "id": "87", "state": "IL", "key": 1000 }, { "city": "Chicago", "id": "7102", "state": "IL", "key": 110 }, { "city": "Crown Point", "id": "7106", "state": "IN", "key": 110038 } ]
Screenshot:
Expected Output:
Add JSR223 PostProcessor as a child of the request which returns the above JSON
Put the following code into "Script" area:
vars.put('cities', new groovy.json.JsonBuilder(new groovy.json.JsonSlurper().parse(prev.getResponseData()).findResults{entry -> entry.city}).toPrettyString())
Refer generated value as ${cities}
where required
Demo:
More information: