All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sol4k.rpc.BigIntegerSerializer.kt Maven / Gradle / Ivy

There is a newer version: 0.5.4
Show newest version
package org.sol4k.rpc

import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind.STRING
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import java.math.BigInteger

internal object BigIntegerSerializer : KSerializer {
    override fun deserialize(decoder: Decoder): BigInteger = decoder.decodeString().toBigInteger()

    override fun serialize(encoder: Encoder, value: BigInteger) = encoder.encodeString(value.toString())

    override val descriptor: SerialDescriptor
        get() = PrimitiveSerialDescriptor("BigInteger", STRING)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy