carp.core-kotlin icon indicating copy to clipboard operation
carp.core-kotlin copied to clipboard

Support other formats than JSON serialization

Open Whathecode opened this issue 6 years ago • 1 comments

This has no priority at all, but, currently the core library presumes the infrastructure layer will rely on JSON serialization to pass data in between submodules (snapshot classes, such as StudyProtocolSnapshot). That is not an unreasonable constraint, given the benefit of not having to worry about serialization at all when using the core libraries which compile to multiple platforms.

However, kotlinx.serialization by itself does not presume any one particular serialization format. The only reason we are currently constrained to using JSON is because of UnknownPolymorphicSerializer, which relies on JSON serialization to work. This serializer is used to be able to deserialize types which are unknown at runtime, thus enabling client-side extensions to be dealt with completely transparently on a server-side that does not have client extensions available at runtime.

Could this implementation become agnostic of the serialization format used? If so, this could make an interesting addition to the kotlinx.serialization library.

Whathecode avatar Jul 11 '19 14:07 Whathecode

Seems like relevant changes might be coming up in a new kotlinx.serialization release, but I haven't look at it in detail yet: https://github.com/Kotlin/kotlinx.serialization/issues/608

Whathecode avatar Jul 24 '20 13:07 Whathecode