如何在 Swift 中优雅地处理 JSON

如何在 Swift 中优雅地处理 JSON


眼眸繁星
浏览 692回答 4
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,},......] 

侃侃尔雅

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}}}}
打开App,查看更多内容
随时随地看视频慕课网APP