【发布时间】:2015-10-27 17:10:54
【问题描述】:
我正在尝试使用 Alamofire 调用 JSON 数组中的对象。 我可以让 Alamofire 解析我的文件,但是我找不到获取特定参数的方法。
如果我使用:
Alamofire.request(.GET, "https://example.com//users_result.json")
.responseJSON { response in
print(response.result) // result of response serialization
if let JSON = response.result.value {
print(JSON.count)
print("JSON: \(JSON[1])")
}
}
代码打印出来:
> SUCCESS 4 JSON: {
> Age = 22;
> Email = "annahswift@gmail.com";
> Location = "New York";
> MyText = "Love Music";
> Name = Annah;
> Password = 123456;
> REF = 003;
> "Reg_Date" = "2015-07-30";
> Sex = Female;
> Surname = Swift; }
现在,如何调用参数“名称”?
print("JSON: \(JSON[1][4])") // nil ??
【问题讨论】:
-
How to parse JSON response from Alamofire API in Swift? 的可能副本(这个,或数千个可用的之一。)