I\'m currently working with Codable types in my project and facing an issue.
struct Person: Codable
{
var id: Any
}
Codable needs to know the type to cast to.
Firstly I would try to address the issue of not knowing the type, see if you can fix that and make it simpler.
Otherwise the only way I can think of solving your issue currently is to use generics like below.
struct Person {
var id: T
var name: String
}
let person1 = Person(id: 1, name: "John")
let person2 = Person(id: "two", name: "Steve")