I've tried to construct struct and decode using it, but it only works if all the datatype is same as defined
For example the below code works fine:
{"key1": "stringValue", "key2": intValue, "key3": ["stringData1", "stringData2", "stringData3"]}
struct User: Decodable
{
var key1: String
var key2: Int
var key3: [String]
}
let decoder = JSONDecoder()
let decodedJsonData = try decoder.decode(User.self, from: data)
print(decodedJsonData)
What should I do to decode if key3 contains different data types?
{"key1": "stringValue", "key2": intValue, "key3": ["stringData1", IntData, FloatData]}