SerialDescriptor

Factory to create a new descriptor that is identical to original except that the name is equal to serialName. Usually used when you want to serialize a type as another type, delegating implementation of serialize and deserialize.

Example:

@Serializable(CustomSerializer::class)
class CustomType(val a: Int, val b: Int, val c: Int)

class CustomSerializer: KSerializer<CustomType> {
override val descriptor = SerialDescriptor("CustomType", IntArraySerializer().descriptor)

override fun serialize(encoder: Encoder, value: CustomType) {
encoder.encodeSerializableValue(IntArraySerializer(), intArrayOf(value.a, value.b, value.c))
}

override fun deserialize(decoder: Decoder): CustomType {
val array = decoder.decodeSerializableValue(IntArraySerializer())
return CustomType(array[0], array[1], array[2])
}
}