我有一个请求,根据“状态”,返回两种可能结构的响应列表。
{
"listSize": 2,
"itemList": [
{
"id": ,
"Name": "",
"submittedOn": "",
"Reference": null,
"status": "Receipted",
"response": null
},
{
"id": 12345,
"submittedOn": "",
"Reference": null,
"status": "Failed",
"response": {
"xml": "",
"formErrors": [
{
"error_type": "",
"error_location":"",
"error_message": "",
}
]
}
},
]
}
我需要检查状态“已收到”或“失败”的结构。在 Java 中,我将使用 for 循环和其中的 if 语句来根据“状态”字段使用不同的条件检查响应字段。 (如下例)
for (int i = 0; i < response.length; i++){
if (response[i].status.equals("receipted")){
//do something
}
else{ //failed
//do something else
}
}
我怎样才能在空手道中实现类似的目标?我应该使用 Java 助手吗?