• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file was automatically generated from json.md by Knit tool. Do not edit.
2 package example.exampleJson08
3 
4 import kotlinx.serialization.*
5 import kotlinx.serialization.json.*
6 
7 enum class Color { BLACK, WHITE }
8 
9 @Serializable
10 data class Brush(val foreground: Color = Color.BLACK, val background: Color?)
11 
<lambda>null12 val json = Json {
13   coerceInputValues = true
14   explicitNulls = false
15 }
16 
mainnull17 fun main() {
18     val brush = json.decodeFromString<Brush>("""{"foreground":"pink", "background":"purple"}""")
19   println(brush)
20 }
21