1 // This file was automatically generated from serializers.md by Knit tool. Do not edit. 2 package example.exampleSerializer23 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 @Serializer(forClass = Project::class) 23 object ProjectSerializer 24 mainnull25fun main() { 26 val data = Project("kotlinx.serialization").apply { stars = 9000 } 27 println(Json.encodeToString(ProjectSerializer, data)) 28 } 29