I have a response in terms of a json object and want to save only the id for hpr number "431002790" that I have from a previous request. here is the response:
[
{
"id": "39d927fd-c634-45ab-b03c-17a1f0309576",
"fullName": "Ali Fos Domus",
"hpr": 431002235,
"role": "Doctor"
},
{
"id": "30ef1935-7999-4d44-bf21-17a1f03224cd",
"fullName": "Bengt Fos Minde",
"hpr": 431002790,
"role": "Doctor"
},
{
"id": "d590bac9-7aad-49d5-9a02-17a1f0316b72",
"fullName": "Bengt Fos Mo",
"hpr": 6165222,
"role": "Doctor"
}
I have tried something like:
.check(jsonPath("$..[?(@.hpr==\"431002790\")].id").saveAs("idHp")))
But I guess the maybe the order of the json structure might be a problem?
hpr is an int, not a String, so you should do:
.check(jsonPath("$..[?(@.hpr==431002790)].id").saveAs("idHp")))