1 // This file was automatically generated from serializers.md by Knit tool. Do not edit. 2 package example.exampleSerializer24 3 4 import kotlinx.serialization.* 5 import kotlinx.serialization.json.* 6 import kotlinx.serialization.encoding.* 7 import kotlinx.serialization.descriptors.* 8 9 // NOT @Serializable, will use external serializer 10 class Project( 11 // val in a primary constructor -- serialized 12 val name: String 13 ) { 14 var stars: Int = 0 // property with getter & setter -- serialized 15 16 val path: String // getter only -- not serialized 17 get() = "kotlin/$name" 18 19 private var locked: Boolean = false // private, not accessible -- not serialized 20 } 21 22 @OptIn(ExperimentalSerializationApi::class) 23 @Serializer(forClass = Project::class) 24 object ProjectSerializer 25 mainnull26fun main() { 27 val data = Project("kotlinx.serialization").apply { stars = 9000 } 28 println(Json.encodeToString(ProjectSerializer, data)) 29 } 30