I'm using Retrofit with Gson, and and when some field is incorrect, I'm not receiving an exception until try to read the value - only then I'm getting a
NullPointerException
Is there a way to enable exceptions for non null fields when deserialization fails?
y
yschimke
05/13/2022, 8:20 AM
You'll probably get an answer here, but isn't this more a GSON question? Something you would need to configure on your com.google.gson.Gson instance?
k
kenkyee
05/13/2022, 10:13 AM
Answer is no. Because that is why people don't use gson with kotlin.
It doesn't understand kotlin null ability.
Use Moshi or kotlinx.serialization...