liveBook · Manning

Serialized reference object

As explained in Building User-Friendly DSLs

A serialized reference object is a JSON object that represents an AST reference relation by storing the target object's identifier in a refId field.

A serialized reference object is a JSON object shaped like { refId: <ID> }. It represents an AST reference relation without embedding the target object, allowing cyclic relations to cross a JSON boundary. section 7.3 section 7.6

Deserialization resolves these objects through a staged transformation:

  • Record unresolved reference IDs, then replace each placeholder with { ref: <target AST object> } after all objects are available. section 7.3
  • Preserve an unselected reference target by converting { refId: undefined } into { ref: undefined }. section 7.3

Resolving an attribute reference

A serialized Attribute Reference can contain { refId: "SlLaELvAy0" }, while the lookup table maps that ID to the Data Attribute object named “rental price before discount.” Deserialization restores the relation as a JavaScript object reference.

How Building User-Friendly DSLs covers it

How deep it goes
Explains detection, ID lookup, deferred resolution, and undefined targets, stopping short of general serialization internals.
Examples
Uses an Attribute Reference pointing to a Data Attribute and demonstrates restoration through an ID-indexed lookup table.
What it assumes
Assumes AST objects, IDs, and reference relations while handling unresolved targets explicitly.
What you can do after
Apply it via a deserializer to restore AST reference objects from serialized JSON.
How it connects
Connects ASTs, JSON serialization, deserialization, reference relations, and depth-first tree traversal.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.