question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getting java.lang.String cannot be cast to java.lang.Void error

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
klemmjeromecommented, Jun 11, 2020

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 https://github.com/klemmjerome do you have a link to the reported issue? I’m facing the same problem and would love to keep track.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Kotlin/kotlinx.serialization/issues/610#issuecomment-642463787, or unsubscribe https://github.com/notifications/unsubscribe-auth/APQEXMEJO5PHZXORVIF2H6TRWCBC3ANCNFSM4JQZ57BQ .

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found