{
"date" : "20200321",
"time" : "2020-03-21 17:15:00",
"data" : {
"yesterday" : {
"aqi" : 63,
"sunrise" : "06:17",
"fx" : "南风",
"date" : "20",
"week" : "星期五",
"ymd" : "2020-03-20",
"high" : "高温 23℃",
"type" : "多云",
"notice" : "阴晴之间,谨防紫外线侵扰",
"sunset" : "18:23",
"fl" : "4-5级",
"low" : "低温 10℃"
},
"pm10" : 77,
"wendu" : "13",
"forecast" : [
{
"type" : "晴",
"ymd" : "2020-04-03",
"low" : "低温 8℃",
"week" : "星期五",
"fx" : "东南风",
"notice" : "愿你拥有比阳光明媚的心情",
"sunset" : "18:36",
"sunrise" : "05:55",
"high" : "高温 13℃",
"fl" : "<3级",
"date" : "03"
},
{
"type" : "晴",
"ymd" : "2020-04-04",
"low" : "低温 10℃",
"week" : "星期六",
"fx" : "西南风",
"notice" : "愿你拥有比阳光明媚的心情",
"sunset" : "18:37",
"sunrise" : "05:53",
"high" : "高温 19℃",
"fl" : "3-4级",
"date" : "04"
}
],
"shidu" : "24%",
"ganmao" : "极少数敏感人群应减少户外活动",
"pm25" : 17,
"quality" : "良"
},
"cityInfo" : {
"parent" : "天津",
"citykey" : "101030100",
"city" : "天津市",
"updateTime" : "17:03"
},
"status" : 200,
"message" : "success感谢又拍云(upyun.com)提供CDN赞助"
}
解析数组:
let data = json!["data"]["forecast"].arrayValue
for val in data {
let model = WetherModel.init(jsonData: val )
self.dataSource.append(model.notice ?? "")
}
解析字典:
let model = WetherModel.init(jsonData: json ?? "" )
self.dataSource.append(model.message ?? "")