blob: f522b3facfb1cb559d60ad9f450d6ed5d88e5fbd [file] [log] [blame]
// This file was automatically generated from json.md by Knit tool. Do not edit.
package example.exampleJson20
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import java.math.BigDecimal
val format = Json { prettyPrint = true }
fun main() {
val pi = BigDecimal("3.141592653589793238462643383279")
// use JsonUnquotedLiteral to encode raw JSON content
val piJsonLiteral = JsonUnquotedLiteral(pi.toString())
val piJsonDouble = JsonPrimitive(pi.toDouble())
val piJsonString = JsonPrimitive(pi.toString())
val piObject = buildJsonObject {
put("pi_literal", piJsonLiteral)
put("pi_double", piJsonDouble)
put("pi_string", piJsonString)
}
println(format.encodeToString(piObject))
}