1
你們可以幫我創建使用ObjectMapper跟蹤JSON數據的Swift對象嗎?JSON響應數據到Swift對象[ObjectMapper]
[{
"location": "Toronto, Canada",
"three_day_forecast": [
{
"conditions": "Partly cloudy",
"day" : "Monday",
"temperature": 20
},
{
"conditions": "Showers",
"day" : "Tuesday",
"temperature": 22
},
{
"conditions": "Sunny",
"day" : "Wednesday",
"temperature": 28
}
]
}
]
[生成的模型](https://gist.github.com/romainmenke/3d2b7a0ade82ade9395c15fe08353e32) –
@appzYourLife結構不允許類型爲Self的屬性。所以類可以更好地表示可能發生的JSON。一個可用的初始化很難概括。有些人只需要完整數據的對象,而另一些人則不介意不完整的對象。 –
這段代碼能幫助你嗎? –