Are there any plans to decouple serialModule from ...
# serialization
a
Are there any plans to decouple serialModule from serialization engine?
s
Can you elaborate more on this? You mean removing
val serialModule: SerialModule
from
Encoder
interface? Or something else?
a
I encountered several cases in framework development, where I need to gather serialization module during runtime and could have different serialization modules depending on which program modules are loaded. Right now it seems a little bit unreasonable that I have to declare the specific module inside Json object initialization.
Also we already discussed the cases with tree-like object serialization when serial module is more like a property of serializer than the serialization engine.
s
So, you expect modules to be available somewhere statically?
a
Yes, the modules are stored separately from the engine and they are somehow coupled to actual serializers. Right now, I need to build module from parts and create a Json instance for each serialization
Probably the most flexible way is to provide serial module both in the serializer itself and in the global engine and merge them on use.
s
Why do you need new json instance for each serialization? Each serialization uses different module?
a
Yes, it is possible that serialization modules will be loaded dynamically. Of course, I can cache them. Still, I have definition of serializers in one place and the actual serialization in the other place. Right now I need to duplicate the information about descendants in two places. I made a workaround by dumping manually dumping the serial module, but I do not like this solution.
It seems to me that the searializer should know about the serial module it exposes/
Specifically in case of tree-like structures