Skip to content

plastic-karma/kotlinx-serialization-ion

Repository files navigation

kotlinx-serialization-ion

License: MIT Build Status

Kotlin Serialization to and from Amazon Ion format (JVM only).

Usage

Serialize to ION strings

data class DataHolder(val name: String, val id: Int)
// ...
val myData = DataHolder(name = "Fritz", id = 42)
Ion.encodeToString(myData) // == { name : "Fritz", id: 42 }

Deserialize from ION strings

data class DataHolder(val name: String, val id: Int)
// ...
val myIon = """{ name : "Fritz", id: 42 }"""
Ion.decodeFromString<DataHolder>(myIon) // == DataHolder(name = "Fritz, id = 42)

Serialize to binary ION

data class DataHolder(val name: String, val id: Int)
// ...
val myData = DataHolder(name = "Fritz", id = 42)
Ion.encodeToBytes(myData) // == binary ION values

Deserialize from binary ION

data class DataHolder(val name: String, val id: Int)
// ...
val myIon: ByteArray = //... get bytes
Ion.decodeFromBytes<DataHolder>(myIon) // == DataHolder(name = "Fritz", id = 42)

About

Kotlin serialization plugin for Amazon ION

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages