如何解决我想用空手道响应验证json匹配的一部分
* def responseJson =
"""
{
"name": "John","age": 30,"cars": {
"car1": "Ford","car2": "BMW","car3": "Fiat"
},"bikes": {
"bike1": "b1","bike2": "b2","bike3": "b3"
}
}
"""
问题:我想比较json的一部分。我试图利用空手道的“包含” dsl,但没有成功。下面的代码参考:
def expectedJson1 =
"""
{
"car1": "#string","car2": "#string","car3": "#string"
}
"""
* def expectedJson2 =
"""
{
"car1": "#string","car2": "#string"
}
"""
* def expectedJson3 =
"""
{
"car1": "#string"
}
"""
* match responseJson contains '#(^expectedJson1)'
* match responseJson contains '#(^expectedJson2)'
* match responseJson contains '#(^expectedJson3)'
我不想使用json路径进行键/值比较,因为实际响应json读取起来相当复杂。因此想随机进行部分匹配。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。