I have some codable struct and I'd like to create a [String:Any] dictionary from it to iterate over its properties. I created a computed property:
var dictionary: [String: Any] {
return (try? JSONSerialization.jsonObject(with: JSONEncoder().encode(self), options: [])) as? [String: Any] ?? [:]
}
When I iterate over the dictionary and try to cast 'Any', types like 'Data' and 'Date' never work. Casting works only for 'String', 'Int' and 'Double'. Is it possible to cast the 'Data' and 'Date' somehow? Thank you in advance.