I saw that it's possible to parse dynamic objects in Javascript to data classes using koltinx.serialization https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/runtime_usage.md#dynamic-object-parser-js-only
I think it would be a useful addition to be able to serialize directly into a dynamic object as well.
At the moment I can only do this (and go through an intermediate String instance):
val jsonString = kotlinx.serialization.json.JSON.stringify(kotlinData)
val dataAsPureJs = kotlin.js.JSON.parse(jsonString)
However it would be nice to be able to do this without the intermediate representation.
Any plans for thought when this feature might be added to this library? This would be a huge win for frameworks where you have to work a lot with json objects to persist and restore data.
Is this still not possible at this time?
Nope :(
Would it be possible to create a JS-platform-only AbstractSerialFormat that spits out dynamic or Json?
Yep, that's how it should be done. Similar to DynamicObjectParser.
Would a PR be welcome?
Fixed in #628
Most helpful comment
Would a PR be welcome?