Is there a way I could solve this issue?
# announcements
m
Is there a way I could solve this issue?
c
Maybe use
lateinit
on those properties?
m
Well, my expectation is that when Gson puts a null to, e.g. objectType, I should have an exception thrown. To my understanding lateinit would not do it.
d
GSON doesn't throw exceptions for missing fields out of the box like moshi does - you'd need to implement a custom deserializer, which would do a null check, then call into the default impl.
Although I'm rather surprised kotlin doesn't complain / throw an exception when you try to access those fields or when they are set?
m
@Dustin Lam no, kotlin is not complaining, at least in my code...