Use the format selector to choose DUST, JSON, EDN or TRON. Text formats supply text; TRON supplies bytes. The scene below declares the selected input explicitly, then calls parse with that format. Parsing creates a native document handle.

Serialize the document when you need bytes or text at an application boundary. Changing the selector changes the actual example input and parser format, rather than guessing a format from the contents.

Serialize the people document

peopleText holds this document:

dust232B
#_ada {name Ada
       role engineer
       age  36}
#_bob {name   Bob
       role   engineer
       age    41
       mentor {#link #_ada}}
#_cy  {name Cy
       role designer
       age  29}
#_tx  {author smoke
       reason seed}
go293B
people, err := stardust.Parse(peopleText, stardust.DUST)
if err != nil {
	return err
}
defer people.Close()

output, err := people.Serialize(stardust.DUST, 0)
if err != nil {
	return err
}

result, err := stardust.Parse(output, stardust.DUST)
if err != nil {
	return err
}
defer result.Close()
Result / 244B
{#_ada {name Ada
        role engineer
        age  36}
 #_bob {name   Bob
        role   engineer
        age    41
        mentor {#link #_ada}}
 #_cy  {name Cy
        role designer
        age  29}
 #_tx  {author smoke
        reason seed}}

The result preserves the people document. The scene serializes in the selected format and reparses those bytes to verify the boundary. See Formats and conversion for fidelity limits: every conversion is not a lossless round trip.