Deserialization reconstructs a structured in-memory AST from its serialized JSON form. It makes persisted ASTs available again after storage on a backend or transfer over HTTP, so a frontend can retrieve and use the saved model. section 7.0
For an AST, reconstruction must preserve both contained objects and reference relations. Serialized references use objects such as `{ refId: id }`; deserialization replaces each with `{ ref: astObject }`, where `astObject` is the reconstructed object with that ID. An unselected target remains `{ ref: undefined }`. section 7.3
A practical implementation uses a depth-first traversal with deferred reference resolution:
- Recognize AST objects, arrays, primitive values, and serialized reference objects separately. section 7.3
- Create a new AST object for every serialized AST object rather than modifying the serialized input. section 7.3
- Record each reconstructed object in an ID-to-AST lookup table. section 7.3
- Collect references while traversing, then resolve their IDs after all AST objects have been created; this supports references whose targets appear later in the structure. section 7.3
Restoring a saved AST
After reading JSON contents from storage, pass the result to `deserialize` and use the returned AST. A serialized Attribute Reference holding `refId: "SlLaELvAy0"` is restored to a JavaScript reference to the reconstructed Data Attribute with that ID. section 7.3
Deserialization can also construct an observable AST directly. Creating observable AST objects and reference wrappers explicitly before linking references avoids MobX recursively converting a circular reference and hitting a maximum call stack error. The resulting reference remains a real observable relation, so dependent projections update when the referenced attribute changes. section 7.4
Figure 7.2 What serialization and deserialization do, and how they relate to each other
Compare the stored representation with the reconstructed AST and see serialization and deserialization as opposite transformations. section 7.0









