Hey everyone, I have the following response classe...
# serialization
r
Hey everyone, I have the following response classes. Check this to get some more context about why I have structured it as below.
Copy code
@Serializable
sealed interface PaginatedItems

@Serializable
data class GetPaginatedResponse(
    val isNext: Boolean,
    val content: PaginatedItems
)

@Serializable
data class TracksPage(
    val items: List<TrackInfo>
) : PaginatedItems
Now, when I hit my endpoint I get the following json
Copy code
{
  "isNext": false,
  "content": {
    "type": "io.github.rubenquadros.vibesync.server.model.MediaPage",
    "items": []
  }
}
I don't understand how this
type
param is getting added in the json
a
that's the discriminator, KxS adds it automatically when encoding polymorphic types https://github.com/Kotlin/kotlinx.serialization/blob/v1.6.3/docs/polymorphism.md#sealed-classes
r
Thanks for sharing! 🙌