I am trying to decode the response I am receiving from API, the response can be 0/1/"skip" so it can be Int or String. How do I define this variable? I have tried to define as: String / String? / Int / Int? , but none of these worked, all throwing an error.
Code:
struct DatesData: Decodable {
let state: String?
let date: String? <-- getting the error here
enum CodingKeys: String, CodingKey {
case state
case date = "dates"
}
}
Response is coming in like this:
{
dates = "2021-03-26";
state = 0;
},
{
dates = "2021-03-27";
state = 1;
},
{
dates = "2021-03-28";
state = skip;
}
Thanks in advance