如何匹配空手道中的地图列表?

How to match against list of maps in Karate?

我有一个列表:

[{
  "a": 1
  "b": 2
}]

我想这样匹配:

And match response contains 
"""
[{
   "a": 1
}]
"""

但是这不起作用,因为响应列表中的地图有更多键。我只想忽略它们。有简单的方法吗?

有两种方法可以做到这一点:

* def response = [{ a: 1, b: 2 }]
* def expected = { a: 1 }
* match response contains '#(^expected)'

或者您可以使用 contains deep:

* match response contains deep { a: 1 }