jmeter - Jmeter:如何使用 if 控制器检查 json 响应值是否为空
问题描述
如何使用jmeter中的if控制器检查空响应值?
我的 json 响应看起来像:{ userID: null }
在 Jmeter 中使用 if 控制器,我想验证,userID 为 null
我正在使用: "${userID}"==null 但这不起作用。
解决方案
您发布的内容看起来不像是有效的 JSON,您可以使用JSONLint服务进行仔细检查
如果您的响应是有效的 JSON,例如,它看起来像:
{
"userID": null
}
您可以使用以下__groovy() 函数作为 If Controller 的条件:
${__groovy(new groovy.json.JsonSlurper().parse(ctx.getPreviousResult().getResponseData()).userID==null,)}
更多信息:
推荐阅读
- android - 如何在 15 秒后从服务启动处理程序以防止应用程序睡眠并将位置发送到 Web 服务?
- sass - gulp sass 在简单的 gulp-sass 测试中失败
- jquery - Consume XML RSS feed using jquery in a predefined template
- ag-grid - 当 stopEditingWhenGridLosesFocus 选项为 true 时,DatePicker 不起作用
- testing - 如何设置邮递员测试等于这个或那个
- c# - 构建失败,因为我杀死 vhost.exe 后无法复制 DLL
- python - 如何从立体获取深度图 - KITTI 数据集
- android - Android 房间数据库 - LiveData - 更新/插入/删除,跳过观察者(回调)
- .net - .NetCore SignalR + React - CORS 调用不起作用
- qlikview - 使用 PPtxgen 将 HTML 表格转换为 PPT