When I send a request to an api end point, the following json is coming in my response.
{
"entities": {
"practitioners": {
"f1d26a4b-c489-493d-bccf-7b9c8b92ecac": {
"fullAvatarUrl": null,
"id": "f1d26a4b-c489-493d-bccf-7b9c8b92ecac",
"accountId": "ef757dba-f0d5-4464-a338-4a810e02bf47",
"pmsId": "1",
"type": "Dentist",
"isActive": true,
"isHidden": false
},
"ee87642d-c9a6-4a9d-b99a-a96501f27a7b": {
"fullAvatarUrl": null,
"id": "ee87642d-c9a6-4a9d-b99a-a96501f27a7b",
"accountId": "ef757dba-f0d5-4464-a338-4a810e02bf47",
"pmsId": "2",
"type": "Hygienist",
"isActive": true,
"isHidden": false
},
"d0aeb9eb-f267-45ad-8cdf-eada1155c274": {
"fullAvatarUrl": null,
"id": "d0aeb9eb-f267-45ad-8cdf-eada1155c274",
"accountId": "ef757dba-f0d5-4464-a338-4a810e02bf47",
"pmsId": "3",
"type": "Dentist",
"isActive": true,
"isHidden": false
},
"2f641e8e-c5d6-4fdf-8fbe-f99fe837f441": {
"fullAvatarUrl": null,
"id": "2f641e8e-c5d6-4fdf-8fbe-f99fe837f441",
"accountId": "ef757dba-f0d5-4464-a338-4a810e02bf47",
"pmsId": "4",
"type": "Hygienist",
"isActive": true,
"isHidden": false
}
}
},
"result": [
"f1d26a4b-c489-493d-bccf-7b9c8b92ecac",
"ee87642d-c9a6-4a9d-b99a-a96501f27a7b",
"d0aeb9eb-f267-45ad-8cdf-eada1155c274",
"2f641e8e-c5d6-4fdf-8fbe-f99fe837f441"
]
}
problem statement: I want to select any one from the above 4 random value(want to select the practitioners id and which are sitting at the first element under practitioners) with a validation that isActive
should be true
and isHidden
should be false
.
I have tried using the JSON extractor using the expression $.entities.practitioners
and match number 0
But it is not selecting the any one rather it select all.
question from:
https://stackoverflow.com/questions/65871476/select-random-value-from-the-response-json-with-a-validation 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…