我想解析这个JSON
Home.swift
self.resultFromJsonGlobal = (dict?["restaurants"]as?[[String : AnyObject]])!
// let annotionsArray: NSMutableArray = NSMutableArray()
for resultFromJson in self.resultFromJsonGlobal
{
let socialType = resultFromJson["social_type"]as? String
let role = resultFromJson["role_code"]as? String
let Price = resultFromJson["price"]as? Strin
let rate = resultFromJson["ratings"]as? String
let ImageUrl = resultFromJson["image"]as? String
let Discriptions = resultFromJson["descriptions"]as? String
}
我得到了socialType,role,rate,ImageUrl的价值。但我没有得到价格和描述的价值。
答案 0 :(得分:0)
试试这段代码。
self.resultFromJsonGlobal = (dict?["restaurants"]as?[[String : AnyObject]])!
// let annotionsArray: NSMutableArray = NSMutableArray()
for resultFromJson in self.resultFromJsonGlobal
{
let socialType = resultFromJson["social_type"] as? String
let role = resultFromJson["role_code"] as? String
let rate = resultFromJson["ratings"] as? String
let ImageUrl = resultFromJson["image"] as? String
if let items = resultFromJson["items"] as? [Any]
{
for item in items
{
let dic = item as! [String:Any]
let Price = dic["price"] as? String
let Discriptions = dic["descriptions"] as? String
}
}
}