jvmMain.kr.jadekim.jext.kotlinx.serialization.serializer.BigIntegerSerializer.kt Maven / Gradle / Ivy
package kr.jadekim.jext.kotlinx.serialization.serializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import java.math.BigInteger
object BigIntegerSerializer : KSerializer {
override val descriptor = PrimitiveSerialDescriptor(
serialName = "BigInteger",
kind = PrimitiveKind.STRING,
)
override fun serialize(encoder: Encoder, value: BigInteger) {
encoder.encodeString(value.toString())
}
override fun deserialize(decoder: Decoder): BigInteger = decoder.decodeString().toBigInteger()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy