postman - 如何在邮递员中验证 JSON 数组值?
问题描述
{
"success": {
"text": "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");
});
推荐阅读
- html - 在 HTML 表单中,“必需”属性不起作用
- laravel - 如何为 laravel 强化路线设置名称?
- c++ - 删除文件 C++ 中的向量元素
- go - 将一个 Golang 结构加入另一个
- sql-server - SQL Server Management Studio:将数据从一个数据库传输到另一个数据库
- c# - Microsoft.SqlServer.Management.Common.ServerConnection 构造函数不接受 SqlConnection,但它应该
- parsing - 模式匹配不允许我更改值
- ruby-on-rails - 使用 OmniAuth 进行设计和第 3 方授权的自定义字段为空白
- python - 在 python 中使用 JSON
- assembly - 汇编吐出原始二进制文件(写入系统调用)