有人可以请我了解如何验证响应中的项目列表。假设响应如下所示,
{
"store":{
"book":[
{
"author":"Nigel Rees",
"category":"reference",
"price":8.95,
"title":"Sayings of the Century"
},
{
"author":"Evelyn Waugh",
"category":"fiction",
"price":12.99,
"title":"Sword of Honour"
},
{
"author":"Herman Melville",
"category":"fiction",
"isbn":"0-553-21311-3",
"price":8.99,
"title":"Moby Dick"
},
{
"author":"J. R. R. Tolkien",
"category":"fiction",
"isbn":"0-395-19395-8",
"price":22.99,
"title":"The Lord of the Rings"
}
]
}
}
元素 Book 在它下面有四个带有不同数据的列表,现在如果我想按顺序验证作者姓名和价格(例如在循环中),我该如何实现..?
我通常将响应转换为 Json 文档,然后进行验证,但在这种情况下,如果我使用 Json 路径“Store.book.author”,则在响应的四个列表中,它会引用哪个列表..?这就是我的困惑所在。