After constructed the codable, getting an error.
"msg": {
"success": [
"Successfully logged in."
]
},
"messages": []
}
// Constructed the codable for the parsing response data
struct Msg:Codable{
let success: [String]?
enum CodingKeys: String, CodingKey{
case success = "succcess"
}
init (from decoder: Decoder)throws{
let value = try decoder.container(keyedBy: CodingKeys.self)
sucess = try values.decodeIfPresent([String].self, forKey: .success)
}
}
I got this error when doing codable
erro typeMismatch(Swift.Dictionary<swift.string, Any>. Swift.DecodingError.Context ( codingPath: [CodingKeys(StringValue:"msg", intValue:nil], debugDescription: Expected to decode Dictionary <String,Any> but found an array instead."underlyingError: nil))
How to resolve this part based on server response.