我需要根据嵌套JSON响应中的条件提取一个元素。
{
"cabin":"eco",
"seatNumber":"15A",
"travelers":[
{
"id":"7789",
"seatCharacteristicsCodes":[
"CH",
"W"
],
"seatAvailabilityStatus":"available",
"prices":[
{
"base":40,
"total":40,
"currencyCode":"AED",
"totalTaxes":0
}
]
}
],
"coordinates":{
"x":1,
"y":0
}
}
我需要检查“seatAvailabilityStatus”是否为“available”(在“travelers”中),如果可用,我需要获取“seatNumber”并继续该流程。
我看过一些例子,并尝试了如下所示的方法,但我只能捕获与“旅行者”相关的值,如“id”或“prices”:
$.travelers[?(@.seatAvailabilityStatus=="available")].id
但在我的情况下,如果seatAvailabilityStatus可用,我需要得到“seatNumber”。有人能帮忙吗?
Screen shot of the JSON I included
2条答案
按热度按时间0wi1tuuw1#
您可以尝试以下方法:
t0ybt7op2#
由于JsonPath doesn't know anything about parents of the matched attribute需要升级一级
建议查询:
演示:
更多信息:How to Use the JSON Extractor For Testing