ktoon
5.0.0indexedSerializer for TOON 3.0.1 with full spec support, encoding/decoding, JSON↔TOON conversion, char-array optimized performance and configurable delimiters, indentation, and key folding.
Serializer for TOON 3.0.1 with full spec support, encoding/decoding, JSON↔TOON conversion, char-array optimized performance and configurable delimiters, indentation, and key folding.
Kotlin serializer for TOON (Token-Oriented Object Notation).
To learn about the TOON format and why you should use it read the official website:
Using the Gradle Kotlin DSL:
// build.gradle.kts
dependencies {
implementation("com.lukelast.ktoon:ktoon:VERSION")
}
Using Gradle Version Catalog:
# gradle/libs.versions.toml
[versions]
ktoon = "VERSION"
[libraries]
ktoon = { module = "com.lukelast.ktoon:ktoon", version.ref = "ktoon" }
// build.gradle.kts
dependencies {
implementation(libs.ktoon)
}
For multiplatform projects:
// build.gradle.kts
kotlin {
sourceSets {
commonMain.dependencies {
implementation("com.lukelast.ktoon:ktoon:VERSION")
}
}
}
Using Maven:
<!-- pom.xml -->
<dependency>
<groupId>com.lukelast.ktoon</groupId>
<artifactId>ktoon-jvm</artifactId>
<version>VERSION</version>
</dependency>
import com.lukelast.ktoon.Ktoon
import kotlinx.serialization.Serializable
@Serializable
data class User(val id: Int, val name: String)
fun main() {
encoded = Ktoon.Default.encodeToString(User(, ))
println(encoded)
decoded: User = Ktoon.Default.decodeFromString(encoded)
}
ktoon targets toon-spec: 4.1. Known deviations from the spec:
sortFields = true (opt-in, off by default): emits object fields in sorted order rather
than the encounter order the spec requires.Documented limits (SPEC §15): values and documents nested deeper than maxNestingDepth
containers (default 128) are rejected with a normal error on both encode and decode instead of
exhausting the host stack. The same configurable limit applies to both sides, so anything the
library encodes it can also decode.
Check out the demo project in the demo directory for more examples on how to use Ktoon.
demo/README.md
See the development guide for how to do development.
Surfaced from shared tags and platforms — no rankings paid for.