【发布时间】:2021-08-03 06:52:24
【问题描述】:
我正在尝试根据嵌套 JSON 数组中的值过滤我的 GET 响应 (JSON)。例如:在下面的 JSON 中,我想过滤一个 JSON 数组并使用 Chocolate 作为面糊打印蛋糕的名称。
{
"id": "0001",
"type": "donut",
"name": "Choco Blueberry Cake",
"ppu": 0.55,
"batter":[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" }
]
}
我尝试过类似的方法:
List<String> chocolateCakeList =jsonPath.getList("findAll{it.batter.type=='chocolate'}.name");
和
List<String> chocolateCakeList =jsonPath.getList("findAll{it.batter.it.type=='chocolate'}.name");
两者都返回空列表。
【问题讨论】:
标签: json rest-assured rest-assured-jsonpath