uidsonic.fluid-json-basic.0.9.24.source-code.JSONSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluid-json-basic Show documentation
Show all versions of fluid-json-basic Show documentation
A JSON library written in pure Kotlin (basic variant)
The newest version!
package com.github.fluidsonic.fluid.json
import java.io.*
interface JSONSerializer {
fun serializeValue(value: Any?, destination: JSONWriter, withTermination: Boolean = true)
companion object {
val default: JSONSerializer get() = StandardSerializer
}
}
fun JSONSerializer.serializeValue(value: Any?) =
StringWriter().apply { serializeValue(value, destination = this) }.toString()
fun JSONSerializer.serializeValue(value: Any?, destination: Writer, withTermination: Boolean = true) =
serializeValue(value, destination = JSONWriter.build(destination), withTermination = withTermination)