如何在 Swift 中优雅地处理 JSON
4 回答
收到一只叮咚
TA贡献1821条经验 获得超4个赞
[
{
......
"text": "just another test",
......
"user": {
"name": "OAuth Dancer",
"favourites_count": 7,
"entities": {
"url": {
"urls": [
{
"expanded_url": null,
"url": "",
"indices": [
0,
26
],
"display_url": null
}
]
}
......
},
"in_reply_to_screen_name": null,
},
......]
陪伴而非守候
TA贡献1757条经验 获得超8个赞
let jsonObject : AnyObject! = NSJSONSerialization.JSONObjectWithData(dataFromTwitter, options: NSJSONReadingOptions.MutableContainers, error: nil)
if let statusesArray = jsonObject as? NSArray{
if let aStatus = statusesArray[0] as? NSDictionary{
if let user = aStatus["user"] as? NSDictionary{
if let userName = user["name"] as? NSDictionary{
//Finally We Got The Name
}
}
}
}
- 4 回答
- 0 关注
- 743 浏览
添加回答
举报
0/150
提交
取消