Back to Kotlinx Serialization

Serialization formats

formats/README.md

1.11.018.0 KB
Original Source

Serialization formats

This area of repository contains different libraries with various add-on formats which were not included in the core library.

For convenience, they have same groupId, versioning and release cycle as core library.

FormatArtifact idPlatformStatusNotes
JSONkotlinx-serialization-jsonall supported platformsstable
JSON-Okiokotlinx-serialization-json-okioall supported by Okio platformsexperimentalExtensions on Json for integration with Okio library.
HOCONkotlinx-serialization-hoconJVM onlyexperimentalAllows deserialization of Config object from popular lightbend/config library into Kotlin objects.You can learn about "Human-Optimized Config Object Notation" or HOCON from library's readme.
ProtoBufkotlinx-serialization-protobufall supported platformsexperimental
CBORkotlinx-serialization-cborall supported platformsexperimental
Propertieskotlinx-serialization-propertiesall supported platformsexperimentalAllows converting arbitrary hierarchy of Kotlin classes to a flat key-value structure à la Java Properties.

Other community-supported formats

These formats are community members' projects and are not maintained by the Kotlin team. Please be advised that they are listed here for reference purposes, and some of them may be outdated.

FormatGitHub repo and ArtifactPlatformNotes
Avroavro-kotlin/avro4k
com.github.avro-kotlin.avro4k:avro4k-coreJVM onlyThis library allows serialization and deserialization of objects to and from Avro. It will read and write from Avro binary or json streams or generate Avro Generic Records directly. It will also generate Avro schemas from data classes. The library allows for easy extension and overrides for custom schema formats, compatiblity with schemas defined outside out of the JVM and for types not supported out of the box.
Bsonjershell/kbson
com.github.jershell:kbsonJVM onlyAllows serialization and deserialization of objects to and from BSON.
TOMLPeanuuutz/tomlkt
net.peanuuutz.tomlkt:tomlktall supported platformsMultiplatform encoder and decoder for TOML 1.0.0 compliant. This library aims to provide similar API to the official JSON format (such as TomlLiteral, TomlTable), while adding TOML specific features (such as @TomlComment, @TomlMultilineString).
TOMLakuleshov7/ktoml
com.akuleshov7:ktoml-coreall supported platformsFully Native and Multiplatform Kotlin serialization library for serialization/deserialization of TOML format. This library contains no Java code and no Java dependencies and it implements multiplatform parser, decoder and encoder of TOML.
Minecraft NBTBenWoodworth/knbt
net.benwoodworth.knbt:knbtall supported platformsImplements the NBT format for kotlinx.serialization, and provides a type-safe DSL for constructing NBT tags.
MsgPackesensar/kotlinx-serialization-msgpack
com.ensarsarajcic.kotlinx:serialization-msgpackall supported platformsAllows serialization and deserialization of objects to and from MsgPack.
SharedPreferencesEdwarDDay/serialization.kprefs
net.edwardday.serialization:kprefsAndroid onlyThis library allows serialization and deserialization of objects into and from Android SharedPreferences.
XMLpdvrieze/xmlutil
io.github.pdvrieze.xmlutil:serializationall supported platformsThis library allows for reading and writing of XML documents with the serialization library. It is multiplatform, providing both a shared parser/writer for xml as well as platform-specific parsers where available. The library is designed to handle existing xml formats that use features that would not be available in other formats such as JSON.
YAMLhim188/yamlkt
net.mamoe.yamlkt:yamlktall supported platformsAllows serialization and deserialization of objects to and from YAML. Basic serial operations have been implemented, but some features such as compound keys and polymorphism are still work in progress.
CBORL-Briand/obor
net.orandja.obor:oborall supported platformsAllow serialization and deserialization of objects to and from CBOR. The serializer supports major type 2 byte string and custom tags.
Amazon Ion (binary only)dimitark/kotlinx-serialization-ion
com.github.dimitark:kotlinx-serialization-ionJVM onlyAllow serialization and deserialization of objects to and from Amazon Ion. It stores the data in a flat binary format. Upon destialization, it retains the references between the objects.
android.os.BundleAhmedMourad0/bundlizer
dev.ahmedmourad.bundlizer:bundlizer-coreAndroidAllow serialization and deserialization of objects to and from android.os.Bundle.
CSVhfhbd/kotlinx-serialization-csv
app.softwork:kotlinx-serialization-csvall supported platformsAllows serialization and deserialization of CSV files. There are still some limitations (ordered properties).
Fixed Length Formathfhbd/kotlinx-serialization-csv-flf
app.softwork:kotlinx-serialization-flfall supported platformsAllows serialization and deserialization of Fixed Length Format files. Each property must be annotated with @FixedLength and there are still some limitations due to missing delimiters.
DynamoDBcodanbaru/DynaMap
com.codanbaru.kotlin:dynamapJVMAllows serialization and deserialization of objects to and from AttributeValue of Amazon DynamoDB
Bencodingiseki0/kotlinx-serialization-bencoding
space.iseki.bencoding:kotlinx-serialization-bencodingall supported platformsAllows serialization and deserialization of objects to and from Bencoding of BitTorrent.
Smilevooft/kotlinx-serialization-smile
io.github.vooft:kotlinx-serialization-smile-coreall supported platformsAllows serialization and deserialization of objects to and from Smile.
PHPjsoizo/kotlinx-serialization-php
com.jsoizo:kotlinx-serialization-phpall supported platformsAllows serialization and deserialization of objects to and from PHP Serialization.
androidx.savedstate.SavedStateandroidx.savedstate
androidx.savedstate:savedstate-ktxall supported platformsSavedState 1.3.0 allows serialization and deserialization of objects to and from androidx.savedstate.SavedState, which is a typealias of android.os.Bundle on Android.
JSON5lisonge/kotlin-json5
li.songe:json5all supported platformskotlin multiplatform json5 for kotlinx.serialization