我有来自api电话的回应:
[{
"1": {
"name": "Euro",
"iso": "EUR",
"sign": "€"
},
"2": {
"name": "Dollar",
"iso": "USD",
"sign": "$"
},
"3": {
"name": "Pound",
"iso": "GBP",
"sign": "£"
},
"6": {
"name": "Czech koruna",
"iso": "CZK",
"sign": "Kč"
},
"7": {
"name": "Australian Dollar",
"iso": "AUD",
"sign": "A$"
}, ...
]
我使用seeResponseMatchesJsonType()方法来验证这个数组,但第一个字段是从1到100的某个数字,在seeResponseMatchesJsonType方法中我必须完全指定字段,
不适合我的代码
seeResponseMatchesJsonType(["1"=> [
"name"=> "Euro",
"iso"=> "string",
"sign"=> "string"
],...
and that code 100 times or what amount ids I will receive))
答案 0 :(得分:0)
根据您的情况,我认为使用seeResponseContainsJson
代替seeResponseMatchedJsonType
会更好。 seeResponseContainsJson
可用于验证响应中是否存在json的一部分。 http://codeception.com/docs/modules/REST#seeResponseContainsJson
希望它有所帮助。