So I used Gson and got this - `java.lang.IllegalAr...
# android
a
So I used Gson and got this -
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter $receiver
does this mean I shouldn't use gson if it swaps stuff out to null behind my back?
hmm maybe I need to make some example code to understand that error better
r
yeah, I would say that when fields are nullable in json making your fields nullable is the best idea when mapping to a json response
a
the field should not be null though, the field should always be present. But json doesn't have a way to specify nullable or not, so it being null is possible.
What I'd like to do is handle this possibility in only one place, instead of having to deal with the property being nullable everywhere
hmm how do I check kotlin nullability using reflection... 🤔
huh kotlin-reflect is big
guess I'll make a new annotation
g
Java json mapping libraries work not so good with nullability. And there is no good solution, as I know, that doesn’t use Kotlin Reflections We use AutoValue + auto-value-gson plugin to achieve nullability validation
Also, respect of nullability from you API could help a lot
a
maybe I should just make a DTO layer