module Psych
def self.load yaml, filename = nil, fallback: false, symbolize_names: false
Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
true value, returns symbols for keys in Hash objects (default: strings).
When the optional +symbolize_names+ keyword argument is set to a
end
ex.message # => "(file.txt): found character that cannot start any token"
ex.file # => 'file.txt'
rescue Psych::SyntaxError => ex
Psych.load("--- `", "file.txt")
begin
Psych.load("---\n - a\n - b") # => ['a', 'b']
Psych.load("--- a") # => 'a'
Example:
Raises a Psych::SyntaxError when a YAML syntax error is detected.
while parsing.
+filename+ will be used in the exception message if any exception is raised
provided, the object contained in the first document will be returned.
Load +yaml+ in to a Ruby data structure. If multiple documents are
##
def self.load yaml, filename = nil, fallback: false, symbolize_names: false result = parse(yaml, filename, fallback: fallback) result = result.to_ruby if result symbolize_names!(result) if symbolize_names result end