请教NSJSONSerialization.JSONObjectWithData 读取json问题

2025-03-01 05:51:02
推荐回答(1个)
回答1:

针对这段json
{
"song": [
{
"picture": "http://img3.douban.com/lpic/s4223250.jpg",
"artist": "伍思凯"
},
{
"picture": "http://img3.douban.com/lpic/s4223250.jpg",
"artist": "伍思凯"
}
]
}
用下面的方法可以数组

varjsonResult:NSDictionary= NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) asNSDictionary
self.data1 = jsonResult["song"] as NSArray
self.table1.reloadData()