如何在邮递员中验证 JSON 数组值?
How can I validate JSON array value in postman?
{
"success": {
"text": "successfully! deleted Records"
}
}
想要验证文本值为 "successfully! deleted Records"
我试过这个
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData[0].text).to.eql("successfully! deleted Records");
});
您正在尝试从 JSON 对象而不是数组中检索数据。因此,应该是这样的。
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.success.text).to.eql("successfully! deleted Records");
});
{
"success": {
"text": "successfully! deleted Records"
}
}
想要验证文本值为 "successfully! deleted Records"
我试过这个
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData[0].text).to.eql("successfully! deleted Records");
});
您正在尝试从 JSON 对象而不是数组中检索数据。因此,应该是这样的。
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.success.text).to.eql("successfully! deleted Records");
});