【发布时间】:2016-07-15 00:27:22
【问题描述】:
{"title" : "saved users", "saved_users_list" :
[
{"username" : "Danny7", "name" : "Danny", "email" : "danny@email.com"},
{"username" : "Ike2016", "name" : "Ike", "email" : "ike@email.com"},
{"username" : "john202", "name" : "John", "email" : "john@email.com"},
{"username" : "ray_mundo", "name" : "Raymundo", "email" : "ray@email.com"}
]
}
我正在尝试用 SwiftyJSON 解析这个 json,但它不起作用。
json["saved_users_list"].count == 0
json["saved_users_list"][0]["username"] does not equal "Danny7"
json["title"] == null
我是这样获取数据的:
Alamofire.request(.POST, url, parameters: parameters).validate().responseString { response in
switch response.result {
case .Success:
if let value = response.result.value {
value = JSON(value)
print(value)
}
}
print(value) 打印上面列出的 json。
【问题讨论】:
-
到目前为止你能分享你的代码吗? (例如,你如何解析 JSON?你怎么知道它看起来像你在这里分享的?)
-
哦,是的,可能是我没有正确地将字符串转换为 json
标签: ios json swift swifty-json