SalomonBrys / Kotson

Kotlin bindings for JSON manipulation via Gson
MIT License
709 stars 37 forks source link

Improve support for `registerTypeAdapter` #22

Closed ColinHebert closed 7 years ago

ColinHebert commented 7 years ago

registerTypeAdapter() now handles JsonSerializer and JsonDeserializer using reified types.

Instead of having this construct GsonBuilder().registerTypeAdapter<MyClass>(jsonDeserializer { MyClass() }) we can infer the type of the Deserializer (or Serializer) GsonBuilder().registerTypeAdapter(jsonDeserializer { MyClass() })

This becomes particularly useful when the Serializer is defined somewhere else because the Serializer that is already typed needs to be registered with the type specified again

SalomonBrys commented 7 years ago

Thanks ;)