xref: /aosp_15_r20/external/kotlinx.serialization/guide/example/example-classes-15.kt (revision 57b5a4a64c534cf7f27ac9427ceab07f3d8ed3d8)
1 // This file was automatically generated from basic-serialization.md by Knit tool. Do not edit.
2 package example.exampleClasses15
3 
4 import kotlinx.serialization.*
5 import kotlinx.serialization.json.*
6 
7 @Serializable
8 class Box<T>(val contents: T)
9 
10 @Serializable
11 data class Project(val name: String, val language: String)
12 
13 @Serializable
14 class Data(
15     val a: Box<Int>,
16     val b: Box<Project>
17 )
18 
mainnull19 fun main() {
20     val data = Data(Box(42), Box(Project("kotlinx.serialization", "Kotlin")))
21     println(Json.encodeToString(data))
22 }
23