【发布时间】:2016-01-26 17:06:27
【问题描述】:
{
"StatusResponse":
{
"StatusCode": "000"
"StatusDescription": "Operation Success(000)"
"DebugDescription": "OperationSuccess"
}-
"memId": "3e369fec-a9c5-418b-a950-0647f7e15d7c"
"token": null
"isAdmin": false
"isTeacher": false
"isParent": true
"kinderId": null
}
这是我的 JSON 格式
Alamofire.request(.GET, "myURL").responseJSON { response in
switch response.result {
case .Success(let data):
let json = JSON(data)
let memId = json["memId"].stringValue
for result in json["StatusResponse"].arrayValue
{
let code = result["StatusCode"].stringValue
print("code = \(code)")
}
print("memId : \(memId)")
case .Failure(let error):
print("Request failed with error: \(error)")
}
}
我的代码和其他代码中有一个 StatusResponse 参数,但是,我可以获取 memId 字符串值,我的代码有任何问题,为什么我无法在此处获取 StatusCode?p>
【问题讨论】:
-
StatusResponse 是字典而不是 arrayValue。
标签: ios json swift swifty-json