Swift Codable - Parse JSON array which can contain different data type
问题 I am trying to parse a JSON array which can be { "config_data": [ { "name": "illuminate", "config_title": "Blink" }, { "name": "shoot", "config_title": "Fire" } ] } or it can be of following type { "config_data": [ "illuminate", "shoot" ] } or even { "config_data": [ 25, 100 ] } So to parse this using JSONDecoder I created a struct as follows - Struct Model: Codable { var config_data: [Any]? enum CodingKeys: String, CodingKey { case config_data = "config_data" } init(from decoder: Decoder)