cph-cachet / carp.core-kotlin

Infrastructure-agnostic framework for distributed data collection.
https://carp.cachet.dk/core/
MIT License
20 stars 2 forks source link

Check out new default polymorphic type handler in `kotlinx.serialization` #161

Closed Whathecode closed 3 years ago

Whathecode commented 3 years ago

In order to handle unknown types we use custom UnknownPolymorphicSerializer in this library.

It seems similar functionality is now supported out-of-the-box in kotlinx.serialization: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#default-polymorphic-type-handler-for-deserialization

We should verify whether or not this provides all the functionality we currently implement ourselves, and replace our implementation with kotlinx.serialization in case it does.

Whathecode commented 3 years ago

If this would work, it is likely we can support other formats than JSON as well: https://github.com/cph-cachet/carp.core-kotlin/issues/33 The main limitation why we cannot do this right now is because UnknownPolymorphicSerializer relies on JSON string manipulations.