There is JSON with root key playlist
that fetch from Retrofit Interface. Gson
library can't parse it to data class. Is there way to do "step into" playlist key before create model?
{
playlist: {
name: "",
description: ""
}
}
data class Playlist(val name: String, val description: String)
CodePudding user response:
Try this
data class PlaylistObject(
val playlist: Playlist
)
data class Playlist(
val description: String,
val name: String
)
CodePudding user response:
You can use that website json to Kotlin, it's very useful specially with long json data. For your case you have two objects, the main object and playlist object, so you need two data classes:
data class PlaylistResponse (
val playlist: Playlist
)
data class Playlist (
val name: String,
val description: String
)