Karate 使用空手道在JsonPath的筛选器部分中使用字符串占位符的表达式

Karate 使用空手道在JsonPath的筛选器部分中使用字符串占位符的表达式,karate,jsonpath,Karate,Jsonpath,我试图使用JSON路径过滤我的响应,其中一个条件使用变量中的值,但我无法正确映射变量,因此我的过滤器无法正常工作 示例响应JSON: { "response":[ { "id":"1234", "confirmationCode":"abcd" } ] } 我使用下面的脚本,其中我使用变量“code”: * def Code = 'abcd' * def value = karate.jsonPath($.response

我试图使用JSON路径过滤我的响应,其中一个条件使用变量中的值,但我无法正确映射变量,因此我的过滤器无法正常工作

示例响应JSON:

{
   "response":[
      {
         "id":"1234",
         "confirmationCode":"abcd"
      }
   ]
}
我使用下面的脚本,其中我使用变量“code”:

* def Code = 'abcd'
* def value = karate.jsonPath($.response[?(@.confirmationCode == ' + Code +')])

请仔细阅读文件:

* def value = karate.jsonPath(response, "$.response[?(@.confirmationCode=='" + Code + "')]")