Skip to content

Instantly share code, notes, and snippets.

@vhart
Last active August 28, 2017 19:08
Show Gist options
  • Save vhart/bb467753dd38e562ca5cdd46cb7e8d59 to your computer and use it in GitHub Desktop.
Save vhart/bb467753dd38e562ca5cdd46cb7e8d59 to your computer and use it in GitHub Desktop.
Without JsonDeserializer as a generic constraint
class SomeDeserializer<T>: JsonDeserializer {
private let deserializer: JsonDeserializer
init<D: JsonDeserializer>(deserializer: D) where D.Response == T {
self.deserializer = deserializer
}
func parse(json: [String : Any]) -> T {
return deserializer.parse(json: json)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment