altavir
05/25/2019, 5:58 PM@Serializer(forClass = StringProperty::class)
object StringPropertySerializer : KSerializer<StringProperty> {
override val descriptor: SerialDescriptor = StringDescriptor
override fun serialize(encoder: Encoder, obj: StringProperty) {
encoder.encodeString(obj.value)
}
override fun deserialize(decoder: Decoder): StringProperty {
return SimpleStringProperty(decoder.decodeString())
}
}
I have two questions:
1. The property is nullable, how can I create a descriptor for nullable value. In @pdvrieze's code there is a delegate wrapper that copies descriptor functionality and switches the nullable
flag. Is i the best way to do so. Do I even need the flag
2. Serialized xml seems to have class names for tag names instead of names of the peoperties. Is it something in serializaition, or a feature of xmlutil
?
3. How can I tell enums to be serializaed into their names. Do I need custom serialized for that?sandwwraith
05/27/2019, 10:19 AMNullableSerializer
and it wraps descriptor automaticallyaltavir
05/27/2019, 10:52 AM