karate - 使用空手道在 JsonPath 的过滤器部分中使用字符串占位符的表达式
问题描述
我正在尝试使用 JSON 路径过滤我的响应,其中一个条件使用变量中的值但我无法正确映射变量,因此我的过滤器无法正常工作。
示例响应 JSON:
{
"response":[
{
"id":"1234",
"confirmationCode":"abcd"
}
]
}
我正在使用以下脚本,其中我正在使用变量“代码”:
* def Code = 'abcd'
* def value = karate.jsonPath($.response[?(@.confirmationCode == ' + Code +')])
解决方案
请仔细阅读文档:
* def value = karate.jsonPath(response, "$.response[?(@.confirmationCode=='" + Code + "')]")
推荐阅读
- django - 使用 Gunicorn 在 Heroku 上部署的 Django Web 应用程序 - 一半的请求随机失败(错误代码 500)
- node.js - 如何使用 node 的实验性 http2-module 选择网络接口?
- php - PHP - 数组格式变量到真实数组
- html - 表格落在 div 容器之外
- java - 将此活动转换为片段
- php - 浏览器不显示任何内容 - 使用 PHP 进行 SQL 查询
- reactjs - 符号不是函数反应酶 i18n 错误
- android - 打开 Android Studio 3.0.1 时出错
- c++ - insert_or_assign 允许迭代器
- android - 检测并发事件编辑