Hi,
When there is a field with a null value, it is written to the notnull field in the Kotlin object. How to make sure that the default value is not overwritten by null
You would need to write a custom TypeAdapter which used Kotlin's reflection library to call the primary constructor and set values via properties. Moshi has an adapter you can port to Gson if you want: https://github.com/square/moshi/blob/master/kotlin/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt, but we won't be adding one to Gson.
Thank you
Hi, does anybody know about solution for Gson? I found https://github.com/sargunv/gson-kotlin but it seems to have some flaws with primitive types (see issue 3), also, reusing full reflection seems quite heavy. Or is it better to switch to other library?
Hi, just curious what's the reason behind not supporting/planning to support it in Gson? does it require a huge refactoring or something?
Most helpful comment
Hi, just curious what's the reason behind not supporting/planning to support it in Gson? does it require a huge refactoring or something?