繁体   English   中英

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

[英]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 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM