commonMain.serialization.SemiColonListSerializer.kt Maven / Gradle / Ivy
package qbittorrent.models.serialization
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
internal object SemiColonListSerializer : KSerializer> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("SemiColonList", PrimitiveKind.STRING)
override fun deserialize(decoder: Decoder): List {
return decoder.decodeString().split(";").filter { it.isNotEmpty() }
}
override fun serialize(encoder: Encoder, value: List) {
encoder.encodeString(value.joinToString(";"))
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy