PrimitiveSerialDescriptor

fun PrimitiveSerialDescriptor(serialName: String, kind: PrimitiveKind): SerialDescriptor

Factory to create a trivial primitive descriptors. Primitive descriptors should be used when the serialized form of the data has a primitive form, for example:

object LongAsStringSerializer : KSerializer<Long> {
override val descriptor: SerialDescriptor =
PrimitiveDescriptor("kotlinx.serialization.LongAsStringSerializer", PrimitiveKind.STRING)

override fun serialize(encoder: Encoder, value: Long) {
encoder.encodeString(value.toString())
}

override fun deserialize(decoder: Decoder): Long {
return decoder.decodeString().toLong()
}
}