This message was deleted.
# announcements
s
This message was deleted.
m
You might want to dive into https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md. I'm not sure you can serialize
List<Any>
but you could serialize
List<BaseType>
where
BaseType
is a super type for all your list elements.
Another option is to work with
JsonElement
then you can construct your
JsonElement
at runtime without having to worry about types
j
I need to serialize to nesting list, something like
[1, [2, 3], 4]
.
m
You can do something like this:
Copy code
JsonArray(
      listOf(
          JsonPrimitive(1),
          JsonArray(
              listOf(
                  JsonPrimitive(2),
                  JsonPrimitive(3),
              )
          ),
          JsonPrimitive(4),
      )
  ).toString()
It's verbose but it'll work