How to parse this json in my code? (Как распарсить этот json в моем коде?). What data model to collect? (какую модель данных собирать?). I don't understand how to cast dictionaries in dictionaries later. (Не пойму как потом кастить словари в словарях).
I get an error opposite let artist:
Value of type 'Dictionary.Element' (aka '(key: String, value: Dictionary)') has no subscripts
func fetchCurrentChartsWithAlamofire(apiMethod: String) {
let url = "https://"
request(url).validate().responseJSON { responseData in
switch responseData.result {
case .success(let value):
guard let jsonData = value as? [String:[String:AnyObject]] else { return }
for artists in jsonData {
let artist = Artist(name: artists["artists"])
}
case .failure(let error):
print(error)
}
}
}
Here is json in the browser:
{
"artists": {
"artist": [
{
"name": "The Weeknd",
}
]
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.