https://kotlinlang.org logo
#announcements
Title
# announcements
m

magisu

10/30/2019, 10:32 PM
Is there a way I could solve this issue?
c

Casey Brooks

10/30/2019, 10:45 PM
Maybe use
lateinit
on those properties?
m

magisu

10/30/2019, 11:29 PM
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

Dustin Lam

10/31/2019, 1:43 AM
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

magisu

10/31/2019, 5:57 PM
@Dustin Lam no, kotlin is not complaining, at least in my code...
2 Views