{
    "content": [
        {
            "type": "text",
            "text": "# Psych::Nodes (ri)\n\n## Sections\n\n- **Psych::Nodes**\n- **Overview** (1 subsections)\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Psych::Nodes",
        "section": "",
        "mode": "ri",
        "summary": null,
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "Psych::Nodes",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "Overview",
                "lines": 36,
                "subsections": [
                    {
                        "name": "YAML AST Requirements",
                        "lines": 33
                    }
                ]
            }
        ],
        "sections": {
            "Psych::Nodes": {
                "content": "(from gem psych-5.4.0)\n------------------------------------------------------------------------",
                "subsections": []
            },
            "Overview": {
                "content": "When using Psych.load to deserialize a YAML document, the document is\ntranslated to an intermediary AST.  That intermediary AST is then\ntranslated in to a Ruby object graph.\n\nIn the opposite direction, when using Psych.dump, the Ruby object graph\nis translated to an intermediary AST which is then converted to a YAML\ndocument.\n\nPsych::Nodes contains all of the classes that make up the nodes of a\nYAML AST.  You can manually build an AST and use one of the visitors\n(see Psych::Visitors) to convert that AST to either a YAML document or\nto a Ruby object graph.\n\nHere is an example of building an AST that represents a list with one\nscalar:\n\n# Create our nodes\nstream = Psych::Nodes::Stream.new\ndoc    = Psych::Nodes::Document.new\nseq    = Psych::Nodes::Sequence.new\nscalar = Psych::Nodes::Scalar.new('foo')\n\n# Build up our tree\nstream.children << doc\ndoc.children    << seq\nseq.children    << scalar\n\nThe stream is the root of the tree.  We can then convert the tree to\nYAML:\n\nstream.toyaml => \"---\\n- foo\\n\"\n\nOr convert it to Ruby:\n\nstream.toruby => [[\"foo\"]]\n",
                "subsections": [
                    {
                        "name": "YAML AST Requirements",
                        "content": "A valid YAML AST must have one Psych::Nodes::Stream at the root.\nA Psych::Nodes::Stream node must have 1 or more Psych::Nodes::Document\nnodes as children.\n\nPsych::Nodes::Document nodes must have one and only one child.\nThat child may be one of:\n\n* Psych::Nodes::Sequence\n* Psych::Nodes::Mapping\n* Psych::Nodes::Scalar\n\nPsych::Nodes::Sequence and Psych::Nodes::Mapping nodes may have many\nchildren, but Psych::Nodes::Mapping nodes should have an even number of\nchildren.\n\nAll of these are valid children for Psych::Nodes::Sequence and\nPsych::Nodes::Mapping nodes:\n\n* Psych::Nodes::Sequence\n* Psych::Nodes::Mapping\n* Psych::Nodes::Scalar\n* Psych::Nodes::Alias\n\nPsych::Nodes::Scalar and Psych::Nodes::Alias are both terminal nodes and\nshould not have any children.\n\n\n\n\n\n\n\n------------------------------------------------------------------------"
                    }
                ]
            }
        }
    }
}