Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jaanussiim/edc8c8e994cc344aae402aca936dd609 to your computer and use it in GitHub Desktop.
Save jaanussiim/edc8c8e994cc344aae402aca936dd609 to your computer and use it in GitHub Desktop.
DictionaryDecoder - close to insanity?
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