🔌 Support of kotlinx.serialization
This module provides support for serializing types from Kotools Types using the kotlinx.serialization library.
You can add this module to your project by using Gradle or Maven.
Just replace the $version
or the ${kotools.types.version}
variables by the
latest version or by another one available
in the changelog.
Important
Note that this module doesn't exist for versions prior Kotools Types 4.5.1.
Gradle - Kotlin DSL
implementation("org.kotools:types-kotlinx-serialization:$version")
Gradle - Groovy DSL
implementation "org.kotools:types-kotlinx-serialization:$version"
Maven
<dependencies>
<dependency>
<groupId>org.kotools</groupId>
<artifactId>types-kotlinx-serialization</artifactId>
<version>${kotools.types.version}</version>
</dependency>
</dependencies>
For using this module, you need to import the serializers module needed when configuring the serialization format. Here's an example of using all serializers from Kotools Types using the JavaScript Object Notation (JSON) format:
val format = Json { serializersModule = KotoolsTypesSerializers.all }
val encoded: String = format.encodeToString(Zero)
println(encoded) // 0
val decoded: Zero = format.decodeFromString(encoded)
println(Zero === decoded) // true
See the API reference of the KotoolsTypesSerializers
type for more details.