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.
Dustin Lam
10/31/2019, 1:46 AM
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...