Currently, I'm dealing with a complex project in TypeScript that heavily relies on object-oriented programming, resulting in a quite intricate object graph (including objects that indirectly point to themselves). My need now is to serialize this graph into a string. Is there any way to achieve this in TypeScript without losing crucial information during de-serialization?
Ideally, I am looking for a solution that minimizes the required bookkeeping on each new class added.
Here are some methods I have experimented with:
JSOG. Unfortunately, this approach was unsuccessful because upon de-serialization, the objects were left as type Object and lost their associated methods.
TypedJSON. This method also failed due to the
error.Uncaught TypeError: cyclic object value
A combination of both approaches: Despite trying to pass an object created by jsog-typescript to TypedJSON, it was rejected for not being the correct type.