SrSouza
04/17/2020, 3:41 PM@Abs val num: Int
=> {"num": -3}
that deserialize to 3.
I already create my owns annotation for Kotlinx.serialization, I know that supports it, but was for a new Enconder of mine, not from a existing one like Json.Dominaezzz
04/17/2020, 5:00 PMabs
. Then annotate the property with the it.Dominaezzz
04/17/2020, 5:02 PMobject AbsSerializer : KSerializer<Int> {
override val descriptor = PrimitiveDescriptor("AbsoluteInteger", <http://PrimitiveKind.INT|PrimitiveKind.INT>)
override fun deserialize(decoder: Decoder): Int {
return abs(decoder.decodeInt())
}
override fun serialize(encoder: Encoder, value: Int) {
encoder.encodeInt(value)
}
}
Dominaezzz
04/17/2020, 5:03 PM@Serializable(with=AbsSerializer::class) val num: Int
SrSouza
04/17/2020, 5:55 PM