https://kotlinlang.org logo
#serialization
Title
# serialization
v

ValV

10/18/2018, 4:27 PM
I have
@Serializable data class MyData (val name: String, val value: Any)
and works pretty good with
MyData.serializer()
until
value
is
java.util.Date
. What is the better way to solve it? Write custom serializer like in https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/custom_serializers.md ?
1
Example for Java's
Date
still does not work, it
Can't locate default serializer for class java.util.Date
I do not understand how serializers are being searched in case when a type inside a class, just creating [companion] object near
MyData
, or inside it, does not work
My bad... I was too impatient to read the whole doc. The problem has been solved with custom
SerialContext
It would be nice to find how to deal with default serial context (if possible)
5 Views