Skip to content

Latest commit

 

History

History
94 lines (77 loc) · 3.89 KB

File metadata and controls

94 lines (77 loc) · 3.89 KB

🔌 Support of kotlinx.serialization

Latest version Embedded Kotlin Kotlin language kotlinx.serialization

JVM Platform JS Platform Linux x64 Platform macOS x64 Platform macOS arm64 Platform MinGW x64 Platform

This module provides support for serializing types from Kotools Types using the kotlinx.serialization library.

🛠️ Installation

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>

👨‍💻 Usage

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.