【发布时间】:2015-08-31 18:15:07
【问题描述】:
我创建了一个函数,该函数使用 Alamofire 通过 POST 请求成功返回 JSON 对象,并且可以使用正确的数据打印该对象。但是,如果我想访问 JSON 中的某个数据点,它要么打印为 null,要么说我以错误的方式访问它。这是我的代码结构,我想知道如何正确编写 print(post.description) 部分
func parseJSON(id:String, found: Bool) -> Dictionary { var dsProperties = 字符串:JSON
Alamofire.request(.POST, urlPath, parameters: parameters)
.responseJSON { (request, response, result) in
if let anError = result.error {
print("error calling POST on /posts")
print(anError)
}
if let result: AnyObject = result.value {
let post: JSON = JSON(result)
for (index: String, subJSON: JSON) in post {
print(post.description) // how can i subscript this
}
}
}
【问题讨论】:
-
是
description一个字符串吗?
标签: swift swift2 alamofire swifty-json