diff --git a/Projects/Shared/Utils/Sources/Extensions/Encodable+.swift b/Projects/Shared/Utils/Sources/Extensions/Encodable+.swift index 337162a..d813533 100644 --- a/Projects/Shared/Utils/Sources/Extensions/Encodable+.swift +++ b/Projects/Shared/Utils/Sources/Extensions/Encodable+.swift @@ -7,3 +7,12 @@ // import Foundation + +extension Encodable { + public func toDictionary() throws -> [String: Any] { + guard let data = try? JSONEncoder().encode(self), + let jsonData = try? JSONSerialization.jsonObject(with: data), + let dictionaryData = jsonData as? [String: Any] else { return [:] } + return dictionaryData + } +}