mrjimin
10/12/2026, 2:50 AM{
"todos": [],
"total": 254,
"skip": 0,
"limit": 30
}
So,
do I absolutely have to use two DTOs (@Serializable)?
Do I really have to use two—`TaskDto` and TasksResponse, which contains it? If so, later on,
{
"code": 200,
"message": null,
"content": {
// data
}
}
Here, “data” refers to everything—it’s just formatted like that.
To achieve that,
@Serializable
data class Dto<T>(
val code: Int,
val message: String? = null,
val content: T
)
Do I absolutely have to create one in this format to extract it?
I’ve always been concerned that doing it that way would require too many classes.arve
10/12/2026, 10:21 AM// from memory, not tested in IDE but roughly:
data class TasksResponse(
val todos: List<TaskDto>,
val total: Int,
val skip: Int,
val limit: Int) {
data class TaskDto(
val id: Int,
val todo: String,
val completed: Boolean,
val userId: Int
)
}arve
10/12/2026, 10:23 AMmrjimin
10/14/2026, 2:32 AMarve
10/14/2026, 6:44 AM