Created
May 3, 2018 11:50
-
-
Save jaanussiim/edc8c8e994cc344aae402aca936dd609 to your computer and use it in GitHub Desktop.
DictionaryDecoder - close to insanity?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class DictionaryDecoder: JSONDecoder { | |
func decode<T>(_ type: T.Type, from dictionary: Any) throws -> T where T : Decodable { | |
let jsonData = try JSONSerialization.data(withJSONObject: dictionary, options: []) | |
return try decode(T.self, from: jsonData) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment