当多个具有相同名称的字段时,如何匹配字段值以进行响应? [英] How to match field value in response when there are multiple fields with the same name?
本文介绍了当多个具有相同名称的字段时,如何匹配字段值以进行响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[
{
"key": "test1",
"category": "test",
"name": "test1",
"translations":
{
"english": "eng"
}
},
{
"key": "test2",
"category": "test",
"name": "test1",
"translations":
{
"english": "eng2",
"german": "German"
}
},
{
"key": "test3",
"category": "power",
"name": "test1",
"translations":
{
"EN_lang": "jik"
}
}
]
在这里,我们有多个具有不同值的字段,我们必须在翻译中匹配值(字段位置在每次调用时都会改变)
Here, we have multiple field's are with different values and we have to match value in translations (field position will change on every call)
推荐答案
您必须清楚要声明的内容.提示,新的contains deep
(在0.9.6.RC4中可用)可以帮助:
You have to be clear about what you want to assert. Hint, the new contains deep
(available in 0.9.6.RC4) can help:
* match response contains deep { key: 'test2', translations: { english: 'eng2' } }
Else you should look at transforming the JSON into a shape where it is easier to do the assertions you want: https://github.com/intuit/karate#json-transforms
这篇关于当多个具有相同名称的字段时,如何匹配字段值以进行响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文