I would like to decode the json data in the following link
However, the rowSet data is an set of json array in inside an array. How to set up the codable struct to decode this data? I am able to set up the following struct to decode the other data.
import Foundation
struct leagueLeader: Codable {
var resource: String
var parameters: parameters
}
struct parameters: Codable {
var LeagueID: String
var PerMode: String
var StatCategory: String
var Season: String
var SeasonType: String
}
struct resultSet: Codable {
var name: String
var headers: [String]
}
The hard part is dealing with
rowSet
that supposed to contains multiple data typesThe solution is to declare an enum that each case has an associated value representing a codable data type
Full of model: