While creating a response model for an API when I initialize the variables and constants with the names that I am going to get from the API response I have to declare their types, i.e. String
, Bool
, Int
.
My question is, is there any way that while initializing all this is there a way that I don't have to define the type of the variables or constants?
Because sometimes if I have declared a variable as String
and in the response JSON the value of that key is Int
the JSON decoder doesn't decode it and fails with an error.
So is there a library or something else I can use that will help me with this?
I have tried JSON decoder and mapper but they didn't or maybe I didn't do it right