Hi, could someone tell me how to define the
data class
to get json like this :
{
"2022": [
{
"name": "foo",
"age": 12
},
{
"name": "bar",
"age": 12
}
],
"2023": [
{
"name": "baz",
"age": 12
}
]
}
I know little about serialization and this is what I wanna do:
import kotlinx.serialization.Serializable
@Serializable
data class Person(
var name: String,
var age: int,
) {}
@Serializable
data class Response(
var ???:Collection<Person> // key is year, what should I put here ?
){
}
or should I take another way?