Monday, 9 September 2019

gson tojson arraylist return null



https://javapapers.com/core-java/java-double-brace-initialization/


https://github.com/google/gson/issues/762

https://wiki.sei.cmu.edu/confluence/display/java/SER05-J.+Do+not+serialize+instances+of+inner+classes



i found that i got [null] when i was running:


 new Gson().toJson(myobjectlist)

even i added the type:


new Gson().toJson(myobjectlist, listType);


i found that because i created myobjectlist by {{}}

double brace will create inner class which doesn't support serialising....

No comments:

Post a comment