You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Double brace initialization actually creates an anonymous class, and Gson does not allow anonymous classes at the moment. Unfortunately it does not handle them in a very user friendly way and just serializes a JSON null, which is omitted from your output because new Gson() omits null values, see also GsonBuilder.serializeNulls().
There is an open discussion about this in #1510, therefore I am closing your issue. Unfortunately no backward compatible solution for this has been found yet.
Gson version
2.10
Java / Android version
Java
Used tools
Description
When creating an instance of a nested class in a normal way:
The result is:
But when instancing
Test2
also in a double braces way:test2
part is gone:Expected behavior
Nested part will also be serialized when in a double braces way.
Actual behavior
It will not.
The text was updated successfully, but these errors were encountered: