https://kotlinlang.org logo
#android
Title
# android
a

adams2

09/19/2017, 6:46 PM
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

reline

09/19/2017, 7:30 PM
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

adams2

09/19/2017, 8:28 PM
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

gildor

09/20/2017, 5:18 AM
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

adams2

09/20/2017, 3:42 PM
maybe I should just make a DTO layer
4 Views