bump on my question from above... is there a way i...
# serialization
r
bump on my question from above... is there a way in kotlin to serialize a json field that can essentially be a union type (either a boolean, or a data class)
k
Defined a sealed interface/class that wraps the type and serialize that
a
the quick-and-easy approach is to manually convert the property to or from a JsonElement
Copy code
@Serializable
data class MyData(
  val someElement: JsonElement,
) {
  val someElementAsBoolean: Boolean? = if (JsonElement is JsonPrimitive) ... else null
}