Can I have a serialization context with a custom property?
Here is the use case: I want to serialize an object graph with repeated object references. I need to avoid serializing an object more than once and I need to break possible cycles. This graph (and any updates to its structure) will be sent in a Ktor/Websocket server session to the JS client. This is the idea:
* Server side: Maintain a per-session set of those objects which have already been serialized or which are known to be present on the client. Object references will be serialized as objects only once. Repeated references will be serialized as object IDs only.
* Client side: Maintain a hash map to resolve references from object IDs.
Server-side serialization needs to access the per session cache. In theory, I could reference this via a derivative of
SerializersModule
, however, the latter is a sealed class. What would be a viable alternative to have a serialization context?