Menu

class: yaml

[37:21] static (extern: com.lehman.aussomserver.connectors.AussomYaml) extends: object

Yaml class supports parsing and creating YAML documents. Use parse and parseFile to read YAML into Aussom values, and dump, dumpAll, or dumpFile to serialize Aussom values back into YAML text. Multi-document YAML files (separated by ---) are handled through parseAll and dumpAll. The serializer handles all native Aussom types: bool, int, double, string, list, map, null, plus the standard Date and Buffer classes (mapped to YAML timestamps and !!binary respectively). Maps emit keys in alphabetical order so generated YAML is stable across runs. File access goes through the Aussom Server file security model. parseFile and dumpFile only see resources that resolve under the app's app_data/ directory (or the public/ directory for read).

Methods

  • parse (string YamlString)

    Parses the YAML in the provided string. The root may be a map, a list, a scalar, or null. Returns the corresponding Aussom value.

    • @p YamlString is a string with the YAML document.
    • @r The parsed value.
  • parseAll (string YamlString)

    Parses a multi-document YAML string, where documents are separated by --- markers, and returns a list of parsed documents.

    • @p YamlString is a string with one or more YAML documents.
    • @r A list of parsed documents.
  • parseFile (string FileName)

    Parses the YAML in the provided file. The file name is validated against the Aussom Server file security model.

    • @p FileName is a string with the path to the YAML file.
    • @r The parsed value.
  • dump (Val, map Options = null)

    Serializes the provided Aussom value to a YAML string. Accepts maps, lists, scalars, Date, and Buffer values. Map keys are emitted in alphabetical order so the output is deterministic.

    • @p Val is the value to serialize.
    • @p Options is an optional map of formatting options. Recognized keys: indent (int) - spaces per indent level (default 2). width (int) - line wrap width (default 80). flow (string) - "block" (default), "flow", or "auto". prettyFlow (bool) - pretty-print flow collections. explicitStart (bool) - emit "---" at the start. allowUnicode (bool) - emit raw unicode (default true).
    • @r A string with the YAML document.
  • dumpAll (list Docs, map Options = null)

    Serializes a list of Aussom values to a multi-document YAML string, with --- separators between documents.

    • @p Docs is a list of values, one per document.
    • @p Options is an optional map of formatting options. See dump for recognized keys.
    • @r A string with the multi-document YAML.
  • dumpFile (Val, string FileName, map Options = null)

    Serializes the provided Aussom value to a YAML file. The file is overwritten if it exists. The file name is validated against the Aussom Server file security model.

    • @p Val is the value to serialize.
    • @p FileName is a string with the path to write.
    • @p Options is an optional map of formatting options. See dump for recognized keys.
    • @r this object.