method
parse
v1_9_3_392 -
Show latest stable
- Class:
Psych
parse(yaml, filename = nil)public
Parse a YAML string in yaml. Returns the first object of a YAML AST. filename is used in the exception message if a Psych::SyntaxError is raised.
Raises a Psych::SyntaxError when a YAML syntax error is detected.
Example:
Psych.parse("---\n - a\n - b") # => #<Psych::Nodes::Sequence:0x00> begin Psych.parse("--- `", "file.txt") rescue Psych::SyntaxError => ex ex.file # => 'file.txt' ex.message # => "(foo.txt): found character that cannot start any token" end
See Psych::Nodes for more information about YAML AST.