data class Foo(val id: String, val uris: List<String>, val option: Option)
data class Option(val bar: String)
Foo("123", listOf("123", "345"), Option("abc"))
into
["123", ["123, "345"], { "bar": "abc" }]
Foo is simply an example. I want to serialize any data class.
v
Vampire
09/26/2020, 10:59 AM
A data class is an object not a list, so I guess you need some conversion. Either using a custom serializer, or by transforming to the wanted list first and then do serialization.
s
Sourabh Rawat
09/28/2020, 7:07 AM
Right. I solved it first transforming it to jsonobject, then for all its values(ignoring keys) i created a jsonarray