I am currently using this extension which works fine for basic objects. I am having a hard time figuring out how to convert nested Codable objects to dictionaries with this call...thanks in advance!
public extension Encodable {
var dictionary: [String: Any]? {
guard let data = try? JSONEncoder().encode(self) else { return nil }
return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? [String: Any] }
}
}