Parse to different type based on property
I am new to Kotlin, and I'm trying to figure out how parsing unknown JSON works.
I have the following set of classes:
@Serializable
abstract class Node {
val name: String = ""
val type: String = ""
abstract val spec: Any
}
@Serializable
class TestNode : Node() {
override val spec: TestNodeSpec = TestNodeSpec()
}
@Serializable
class TestNodeSpec {
val test: String = "testSpec"
}
I can successfully parse an object directly to a TestNode, but for my purpose I want to be...