2017-10-19 85 views
0

我具有从API调用这样的响应:如何验证JSON正确

[{ 
    "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)) 

回答