0
嗨內嵌套的字典我現在有一個JSON提要:斯威夫特3訪問JSON提要
"hourly":{
"summary":"Breezy and partly cloudy tomorrow morning.",
"icon":"wind",
"data":[
{
"time":1479222000,
"summary":"Clear",
"icon":"clear-night",
"precipIntensity":0,
"precipProbability":0,
"temperature":25.09,
"apparentTemperature":25.09,
"dewPoint":21.56,
"humidity":0.81,
"windSpeed":1.13,
"windBearing":72,
"visibility":9,
"cloudCover":0.1,
"pressure":1015.18,
"ozone":242.43
},
{
"time":1479225600,
"summary":"Clear",
"icon":"clear-night",
"precipIntensity":0,
"precipProbability":0,
"temperature":24.18,
"apparentTemperature":24.18,
"dewPoint":20.71,
"humidity":0.81,
"windSpeed":1.42,
"windBearing":76,
"visibility":9,
"cloudCover":0.1,
"pressure":1015.24,
"ozone":242.3
}
]
我可以用下面的代碼訪問「小時工」和「數據」沒問題:
let hourly = json["hourly"] as? [String : Any],
let data = hourly["data"] as? [[String : Any]]
但我需要做的只是在數據中訪問第一個Dictionary
,這是我無法想象的。任何人都可以幫忙嗎?
工作就像一個魅力。非常感謝您的幫助 – user1391152