swift 中的 Alamofire 解析错误
Parse error in Alamofire in swift
我收到了这个回复。
SUCCESS: {
msg = "Login successfully";
"type_id" = 1;
"user_id" = 2;
}
我使用了这个代码。
Alamofire.request(.POST, "http:/www.abc.com" , parameters: ["consumer_key": "Og5pRGI2V"]).responseJSON { response in
print(response)
let employees = response["employees"]! as NSDictionary //getting error type response has no subscript member
}
哪种响应类型?如何解析这个 "msg","user_id" ?提前致谢。
Alamofire 解析响应数据并将其存储在响应对象中。你可以这样得到它:
Alamofire.request(.POST, "http:/www.abc.com" , parameters: ["consumer_key": "Og5pRGI2V"]).responseJSON { response in
print(response)
if let dict = response.result.value {
let msg = dict["msg"]
let userId = dict["user_id"]
// Do things with the values
}
}
我收到了这个回复。
SUCCESS: {
msg = "Login successfully";
"type_id" = 1;
"user_id" = 2;
}
我使用了这个代码。
Alamofire.request(.POST, "http:/www.abc.com" , parameters: ["consumer_key": "Og5pRGI2V"]).responseJSON { response in
print(response)
let employees = response["employees"]! as NSDictionary //getting error type response has no subscript member
}
哪种响应类型?如何解析这个 "msg","user_id" ?提前致谢。
Alamofire 解析响应数据并将其存储在响应对象中。你可以这样得到它:
Alamofire.request(.POST, "http:/www.abc.com" , parameters: ["consumer_key": "Og5pRGI2V"]).responseJSON { response in
print(response)
if let dict = response.result.value {
let msg = dict["msg"]
let userId = dict["user_id"]
// Do things with the values
}
}