jvmMain.kr.jadekim.jext.kotlinx.serialization.serializer.LocaleSerializer.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.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import java.util.*
object LocaleSerializer : KSerializer {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Locale", PrimitiveKind.STRING)
override fun deserialize(decoder: Decoder): Locale = Locale.forLanguageTag(decoder.decodeString())
override fun serialize(encoder: Encoder, value: Locale) {
encoder.encodeString(value.toLanguageTag())
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy