需要解析的 json 是这个: www.zimuzu.tv/resource/index_json/rid/33701/channel/tv (去掉首行的"var index_info=")
可以在 http://tool.oschina.net/codeformat/json 进行可视化
相关代码是这样
let json = try? JSONSerialization.jsonObject(with: data, options: [])
if let dictionary = json as? [String: Any] {
if let array = dictionary["prevue"] as? NSArray {
print(array[0])
}
}
问题是:
{
episode = 9;
"play_time" = "2016-11-28";
season = 1;
t = 1480348800;
week = "\U5468\U4e00";
}
附:官方博客对JSONSerialization的示范代码 :developer.apple.com/swift/blog/?id=37