如果我知道一个特定的值,我如何从JSON中获得某个值。如果我想提取汽车类型并且我知道汽车名称。我尝试了不同的变化:${GetType}= Get Value From Json ${CarList.json()} $..type[?($.name=Focus)]
[
{
"Manuafacture": "BMW",
"Engine": [
{
"volume": 3,
"filter": 222,
"name": "Turbo-dd"
}
],
"name": "320",
"type": "333-44-12"
},
{
"Manuafacture": "Ford",
"Engine": [
{
"volume": 2,
"filters": 1111,
"name": "doch"
}
],
"name": "Focus",
"type": "444-55-33"
},
{
"Manuafacture": "Audi",
"Engine": [
{
"volume": 3,
"filters": 444,
"name": "TFSI"
}
],
"name": "A6",
"type": "999-88-77"
}
]
1条答案
按热度按时间f0brbegy1#
在过滤器表达式中,您引用的不是当前元素(
@
),而是根元素($
)。等号也应该使用两次(==
)。这样的东西应该是可行的:$[?(@.name=="Focus")].type