Kotlin serializer for TOON (Token-Oriented Object Notation).
To learn about the TOON format and why you should use it read the official website:
- https://toonformat.dev/
- TOON specification: https://github.com/toon-format/spec.
- Full TOON 3.0.1 Spec Support - Complete implementation of the TOON format specification, including tabular arrays, key folding, and delimeters. 400+ tests.
- Fully Featured
- Encode Kotlin data classes to TOON
- Encode JSON to TOON
- Decode TOON to Kotlin data classes
- Minimal Dependencies - Only depends on kotlinx.serialization, no additional runtime dependencies.
- High Performance - CharArray-based encoding optimized for minimal allocations and fast string operations.
- Flexible Configuration - Configurable delimiters, indentation, and key folding.
Check JitPack for versions and more installation instructions: https://jitpack.io/#lukelast/ktoon
Using the Gradle Kotlin DSL:
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
mavenCentral()
maven(url = "https://jitpack.io")
}
}// build.gradle.kts
dependencies {
implementation("com.github.lukelast:ktoon:VERSION")
}import com.lukelast.ktoon.Ktoon
import kotlinx.serialization.Serializable
@Serializable
data class User(val id: Int, val name: String)
fun main() {
val encoded = Ktoon.Default.encodeToString(User(1, "Alice"))
println(encoded)
}- This library is built to target Java 17.
- You need kotlinx serialization which requires a build plugin.
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.