Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 1.27 KB

README.md

File metadata and controls

39 lines (33 loc) · 1.27 KB

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)