Karate 空手道中未命名JSON数组字段验证

Karate 空手道中未命名JSON数组字段验证,karate,Karate,我在响应中有一个类似这样的未命名JSON数组,我想检查它是否包含“confirmationNumber”:“pqrs”。我可以知道我怎样在空手道中检查吗 [ { "id": 145, "confirmationNumber": "abcd" },{ "id": 723 "confirmationNumber": "pqrs" } ,{ "id": 7342 "confi

我在响应中有一个类似这样的未命名JSON数组,我想检查它是否包含
“confirmationNumber”:“pqrs”
。我可以知道我怎样在空手道中检查吗

[
    {
        "id": 145,
        "confirmationNumber": "abcd"
    },{
        "id": 723
        "confirmationNumber": "pqrs"
    }
    ,{
        "id": 7342
        "confirmationNumber": "sfeq"
    }
]
对这些情况有好处:

* def response = 
"""
[
   {
      "id":145,
      "confirmationNumber":"abcd"
   },
   {
      "id":723,
      "confirmationNumber":"pqrs"
   },
   {
      "id":7342,
      "confirmationNumber":"sfeq"
   }
]
"""
* def fun = function(x){ return x.confirmationNumber == 'pqrs' }
* def found = karate.filter(response, fun)
* match found == '#[1]'
另请参见JsonPath的示例:

编辑:抱歉,有一个更简单的方法,请

* match response contains { id: '#number', confirmationNumber: 'pqrs' }
* def item = { confirmationNumber: 'pqrs' }
* match response contains '#(^item)'