Roberto Leinardi
01/15/2024, 12:55 PM{
"draw": [
{
"dc": [
28,
4,
3,
"#FF0000"
]
},
{
"dr": [
20,
4,
4,
4,
"#0000FF"
]
},
{
"dt": [
0,
0,
"Hello",
"#00FF00"
]
}
]
}
where the dc, dr and dt can be in any order and amount inside the list, while their values are always the same amount and type (e.g. Int, Int, Int, String for dc and Int, Int, String, String for dt), but as a List.
I'm trying to use Maps and Sealed classes but so far I didn't get anywhere.
What would be the best and easiest way to generate this JSON with kotlinx.serialization? Btw, this is part of a way bigger JSON, but the rest of the JSON can be handled with a normal data class and some `List`s. Also, I only need to serialize it (send this as payload) and I do not have to deserialize it back, in case this could make things easier.Adam S
01/15/2024, 1:50 PMAdam S
01/15/2024, 1:52 PMRoberto Leinardi
01/15/2024, 1:55 PMRoberto Leinardi
01/15/2024, 4:03 PMtype inside the JSON:
"draw":[
{
"dc":[
"type":"io.ks3.Tuple(com.leinardi.kal.model.Draw.Circle)",
28,
4,
3,
"#FF0000"
]
},
{
"dr":[
"type":"io.ks3.Tuple(com.leinardi.kal.model.Draw.Rectangle)",
20,
4,
4,
4,
"#0000FF"
]
},
{
"dt":[
"type":"io.ks3.Tuple(com.leinardi.kal.model.Draw.Text)",
0,
0,
"Hello",
"#00FF00"
]
}
],
Does anyone know how could I get rid of it?Javier
01/15/2024, 5:20 PMRoberto Leinardi
01/15/2024, 6:22 PMJavier
01/15/2024, 6:40 PM