要检查Respondy Body是否有字符串,我可以使用:
tests["Body matches string"] = responseBody.has("string_you_want_to_search");
但我有一个像这样的回应:
{
"total": 20000,
"amount": {
"total": 10000,
"fees": 0,
"refunds": 0,
"liquid": 10000,
"currency": "BRL"
},
}
如何查看字段amount.total?
答案 0 :(得分:0)
使用点运算符进行测试以访问嵌套值:
var data = JSON.parse(responseBody);
tests["10000"] = data.amount.liquid === "10000";
tests["BRL"] = data.amount.currency === "BRL";
希望它有所帮助!