1 // This file was automatically generated from polymorphism.md by Knit tool. Do not edit. 2 package example.examplePoly07 3 4 import kotlinx.serialization.* 5 import kotlinx.serialization.json.* 6 7 @Serializable 8 sealed class Project { 9 abstract val name: String 10 var status = "open" 11 } 12 13 @Serializable 14 @SerialName("owned") 15 class OwnedProject(override val name: String, val owner: String) : Project() 16 mainnull17fun main() { 18 val json = Json { encodeDefaults = true } // "status" will be skipped otherwise 19 val data: Project = OwnedProject("kotlinx.coroutines", "kotlin") 20 println(json.encodeToString(data)) 21 } 22