Lets to say I have the following data class:
data class MyDataClass(@SerializedName("myList") val myList: List<String>)
And I try to parse this JSON:
{ "myList": null } or {}
I want to get an empty list but I get a null myList
. Does anyone know how to serialize this without implementing a registerTypeAdapter
for each type containing a list?
If I set emptyList()
as default value for the constructor. The second JSON works as I want to.