我具有JSON以下的内容,我需要根据自动化脚本中给定的ID验证状态。对于该JSON路径,要求
[
[
{
"id": 9905130204,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
},
{
"id": 9905130203,
"name": "Jeffs Doggie11/6/2019 2:44:53 PM",
"photoUrls": [
"string"
],
"tags": [],
"status": "available"
},
{
"id": 9905130217,
"name": "Goot Doggie",
"photoUrls": [
"https://media.karousell.com/media/photos/products/2017/09/14/doggi_door_stopper_1505372529_5cdd1eba0"
],
"tags": [],
"status": "available"
}
]
]
我想基于"status": "available"
提取"id": 9905130217
。不知道该怎么做,请帮忙。
答案 0 :(得分:2)
您可以使用以下jsonpath表达式查找id = n的状态:
$.[?(@.id == 'n')].status
因此,对于您的具体情况:
$.[?(@.id == '9905130217')].status
请注意,这假定id是唯一的。