Module: OEmbed::Formatter::JSON::Backends::Yaml
Overview
Use the YAML library, part of the standard library, to parse JSON values that has been converted to YAML.
Instance Method Summary collapse
-
#decode(json) ⇒ Object
Parses a JSON string or IO and converts it into an object.
- #decode_fail_msg ⇒ Object
- #parse_error ⇒ Object
Instance Method Details
#decode(json) ⇒ Object
Parses a JSON string or IO and converts it into an object.
13 14 15 16 17 18 19 20 |
# File 'lib/oembed/formatter/json/backends/yaml.rb', line 13 def decode(json) if json.respond_to?(:read) json = json.read end YAML.load(convert_json_to_yaml(json)) rescue ArgumentError, Psych::SyntaxError raise parse_error, "Invalid JSON string" end |
#decode_fail_msg ⇒ Object
22 23 24 |
# File 'lib/oembed/formatter/json/backends/yaml.rb', line 22 def decode_fail_msg "The version of the YAML library you have installed isn't parsing JSON like ruby-oembed expected." end |
#parse_error ⇒ Object
26 27 28 |
# File 'lib/oembed/formatter/json/backends/yaml.rb', line 26 def parse_error ::StandardError end |