So, here is the situation.
Server: Kotin/JVM
Client: VanillaJS
DTO’s that are passed around: XML
This is error prone, because we have two locations where the DTO’s are made and this is difficult to maintain.
I am now investigating creating a separate Web Worker for the DTO generation (they can become quite complicated) and some heavy crunching of data.
Creating a DOMDocument is easy in JVM.
Creating a DOMDocument is easy in JS.
However, there are subtle changes and I need to use a common
module for this to work on both platforms. And kotlin-common supports no DOMDocument.
I know there is the serialization
library. However we have subtle, but documented, variations in our XML which show some fields or not, depending on some cases. Or they show some calculated fields. I don’t exactly know how to solve this with the serialization library.
One of the approaches would be to create a wrapper or interface and have the platforms implement that interface.
Another would be to use the expect
and actual
mechanism.
Are there any other options?