Skip to content
FutureBlitz

    Install

    Import std.data.yaml

    Yaml

    std.data.yaml

    struct

    Public Struct Yaml

    What reads and writes YAML documents, in its Static Methods.

    Examples

    Local document = Try Yaml.Read(r"""
        name: Ada
        langs:
          - en
          - fr
        age: 36
        """)
    Expect(document.Path("langs[0]")?.AsString() == "en")
    Expect(document.Path("age")?.AsInt() == 36)
    Expect((Try Yaml.Read(Yaml.Write(document))) == document)

    std/data/yaml.fb, line 32

    • Public Static Method Read(text: String): Value Throws ParseError static method #

      The document text holds, or Null for a text of none. An integer past what an Int64 holds is a UINT, and past a UInt64 a Double. Throws a ParseError, with its line and column, of UNEXPECTED_END for text that ends inside a quoted scalar or a flow collection, of OUT_OF_RANGE for an !!int past what a UInt64 holds, of OTHER for a tag that isn't the core schema's, a key that's a mapping or a sequence, or a text of more than one document, which ReadAll reads, at the second's start, and of SYNTAX for the rest that isn't YAML 1.2.

    • Public Static Method ReadAll(text: String): Value[] Throws ParseError static method #

      Each document text holds, in order. Throws a ParseError as Read does, but for more than one document.

    • @PanicsAtCaller Public Static Method Write(value: Value): String static method #

      value as a document: an Object as a block mapping, an Array as a block sequence, an empty one as {} or [], and a String plain where the core schema reads it back as that String, else in double quotes. Panics when value holds bytes, which the core schema hasn't got.

    • @PanicsAtCaller Public Static Method WriteAll(values: Value[]): String static method #

      values as documents, each after a "---". Panics as Write does.

    Report an issue with this page or with FutureBlitz on GitHub.