LS
// NodeAbstract.kt
@Serializable
abstract class NodeAbstract : Node {
val attributes: JsonObject = JsonObject(emptyMap())
}
@Serializable
class Impl2 (val s: String): NodeAbstract() {
}
// main.kt
@Serializable
class Impl (val ss: String): NodeAbstract() {
}
fun main() {
val json = Json(JsonConfiguration.Stable.copy(isLenient = true))
println(json.stringify(Impl2.serializer(), Impl2("dasdasdsdasd")))
println(json.stringify(Impl.serializer(), Impl("dasdasdsdasd")))
}
вывод:
{"attributes":{},"s":"dasdasdsdasd"}
{"ss":{},"ss":"dasdasdsdasd"}