We are working on a generic Kotlin Serialization facility for some future release of Kotlin. Goals of this effort are:
- Work with any Kotlin backend (JVM, JS, Native)
- Be compatible with any data serialization format or library (kryo, json, xml, protobuf, Android’s Parcel, anything) including use-cases of loading configuration files from disk and loading/saving objects from/to relational databases
- Support both static serialization formats (type information is taken from compile-time types) and dynamic serialization formats (ones that use run-time types)
- Support both graph serialization formats (object identity is preserved) and value serialization formats
- Support built-in arrays, collections and maps
- Generate code for user-defined classes at compile-time
It is out of scope of the project to design any-Kotlin specific wire format. Support for some popular formats (like JSON) may be provided by a standard library, though. No commitment to any release time-frame at this phase.
This facility is going to supersede and resolve JS serialization issues that are tracked here:
- https://youtrack.jetbrains.com/issue/KT-13428 JS: provide generic way to serialize/deserialize objects
- https://youtrack.jetbrains.com/issue/KT-7939 JS: json serialization
This topic is to gather community use-cases and feedback.