I'm having a hard time finding documentation on how to deserialize date fields. How do i achieve this? Most solutions i found on SO don't work or they use classes that are no longer available
@Serializable
data class Dashboard(
val someNumber: Int,
val someDate: Date? // Custom Deserialization from unix timestamp
)
EDIT: Most solution i found use PrimitiveSerialDescriptor
which seems to be not available
There is good documentation for the latest version of kotlinx.serialization https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serializers.md#custom-serializers
However, there is no
PrimitiveSerialDescriptor
class in the question which means, that some older version of kotlinx.serialization is used.From https://github.com/Kotlin/kotlinx.serialization/releases it could be found out that in version 1.0.0-RC
and
Following that, here is an example of code for kotlinx.serialization version 0.20.0:
with
build.gradle.kts