How to parse JSON with Decodable protocol when property types might change from Int to String? [duplicate]
Well it’s a common IntOrString problem. You could just make your property type an enum that can handle either String or Int. enum IntOrString: Codable { case int(Int) case string(String) init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() do { self = try .int(container.decode(Int.self)) } catch DecodingError.typeMismatch { do { self = try … Read more