I would like to deserialize the following JSON:
{
"participants": {
"0": {
"layout": "layout1"
}
},
"layouts": {
"layout1": {
"width": 100,
"height": 100
}
}
}
Into the following structure:
@Serializable
data class Layout(val width: Int, val height: Int)
@Serializable
data class Participant(val index: Int, val layout: Layout)
@Serializable
data class ViewData(val participants: MutableMap<Int, Participant>, val layouts: MutableMap<Int, Layout>)
What I'm particularly struggling with is how to create the correct relationship between participant's layout using the key "layout1"
in the "layouts"
hash.
Thanks!