-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GSON ignoring kotlin data class null-safety and default value #1657
Comments
this issue is so crucial in my opinion... Is there an update? |
Is this not intentional behaviour? See this: https://stackoverflow.com/a/45793703
|
You can use https://github.com/square/moshi, if null-safety check failed, it will throw an exception. If you want kotlin data class null-safety and default value using moshi, you can reference https://github.com/sparklexin/moshi-kotlin-nullsafe |
This results in Gson creating data objects with possible null values for non-null variables in the following cases:
Any variable that is marked as non-null in the data class but is missing in the JSON
Any variable that is an Enum type and the value passed from the server doesn’t have a matching Enum value on the client
The text was updated successfully, but these errors were encountered: