method
parse
v2_5_5 -
Show latest stable
-
0 notes -
Class: Psych
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (38)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (1)
- What's this?
parse(yaml, filename = nil, fallback: false)
public
Parse a YAML string in yaml. Returns the Psych::Nodes::Document. 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::Document:0x00> begin Psych.parse("--- `", "file.txt") rescue Psych::SyntaxError => ex ex.file # => 'file.txt' ex.message # => "(file.txt): found character that cannot start any token" end
See Psych::Nodes for more information about YAML AST.