We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
` val gson = Gson()
data class TestModel( val id: Int, val description: String ) val jsonString = gson.toJson(TestModel(1,"Test")) println(jsonString)
` why jsonString is null ? who knows ? my kotlin version is 1.4.10. my jdk version is 1.8
The text was updated successfully, but these errors were encountered:
Gson doesn't support serializing anonymous types.
https://stackoverflow.com/questions/39538677/why-does-gson-tojson-always-return-null
Sorry, something went wrong.
我测试了一下,匿名类或者局部类都会有这个问题。 可能Kotlin不支持吧。
As mentioned above, most likely Gson's default behavior for anonymous and local classes caused the null return value.
null
However, in the latest Gson versions this might actually be fixed for local Kotlin data classes due to #1969.
No branches or pull requests
`
val gson = Gson()
`
why jsonString is null ?
who knows ?
my kotlin version is 1.4.10.
my jdk version is 1.8
The text was updated successfully, but these errors were encountered: