请教NSJSONSerialization.JSONObjectWithData 读取json问题
1个回答
推荐于2016-06-15 · 知道合伙人影视综艺行家
关注
展开全部
针对这段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()
{
"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()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询