getting java.lang.String cannot be cast to java.lang.Void error
See original GitHub issueI am getting this error when trying to parse my json
java.lang.String cannot be cast to java.lang.Void
The stacktrace says that the error is coming from the "Movie " class
The classes that I am using are as follows
@Model
@Serializable
data class MovieList(val watchers: Int, val movie: Movie)
@Serializable
data class Movie(val title: String, val year: Int, val ids: MovieIds)
@Serializable
data class MovieIds(val trakt: Int, val slug: String, val imdb: String, val tmdb: Int)
and the json data looks like this
[
{
"watchers": 21,
"movie": {
"title": "TRON: Legacy",
"year": 2010,
"ids": {
"trakt": 1,
"slug": "tron-legacy-2010",
"imdb": "tt1104001",
"tmdb": 20526
}
}
},
{
"watchers": 17,
"movie": {
"title": "The Dark Knight",
"year": 2008,
"ids": {
"trakt": 4,
"slug": "the-dark-knight-2008",
"imdb": "tt0468569",
"tmdb": 155
}
}
}
]
- Kotlin version: 1.3.60-eap-25
- Library version: 0.14.0
- Kotlin platforms: android
- Gradle version: 5.6.1
- IDE version Android Studio 4.0
- Other relevant context: using openjdk 8 on linux
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
How to resolve ClassCastException: java.lang.String ...
You are trying to change List<String> to List<tcmb> and problem ... then, to get the List object with Shared Preferences in the fragment...
Read more >NI: ClassCastException "cannot be cast to java.lang.Void" ...
The following unit test runs OK under Kotlin 1.3.72 but fails with a ClasscastException (cannot be cast to java.lang.Void) under Kotlin 1.4m2 (this...
Read more >How to fix java.lang.classcastexception cannot be cast to in ...
As name suggests ClassCastException in Java comes when we try to type cast an object and object is not of the type we...
Read more >Fixing the JPA error "java.lang.String cannot be cast to ...
In JPA it's not uncommon to get this error when we work with native queries and we use the createNativeQuery method of the...
Read more >How to Fix java.lang.classcastexception in Java?
If we try to print this value by casting to different data type like String or Integer etc., we will be getting ClassCastException....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes : https://issuetracker.google.com/issues/157901343
For me its not a big problem, i just used gson instead of kotlinx serialization and when the bug its fixed i will exchange it ^_^
Roberto Estivill notifications@github.com schrieb am Do., 11. Juni 2020, 09:24:
@klemmjerome see https://github.com/Kotlin/kotlinx.serialization/issues/770#issuecomment-661743674