我有一个像这样的JSON,如果我进行查询
jsonPath($.book[?(@.price)]).is("8.95")
它有效。
{"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
]
}
但是,如果我有一个JSON,其中只有一个对象,那么相同的查询逻辑不会起作用。即jsonPath($.book[?(@.price)]).is("8.95")
有什么想法?
{"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
}
]}
我需要坚持使用查询,因为我不确定API是返回多个对象还是单个对象。
答案 0 :(得分:0)
哦,我发现了Gatling的错误,它无法使用带有一些大括号的查询来解析jsonPath,例如: { or [ or )