module OEmbed::Formatter::JSON::Backends::Yaml

Use the YAML library, part of the standard library, to parse JSON values that has been converted to YAML.

Public Instance Methods

decode(json) click to toggle source

Parses a JSON string or IO and converts it into an object.

# 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() click to toggle source
# 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() click to toggle source
# File lib/oembed/formatter/json/backends/yaml.rb, line 26
def parse_error
  ::StandardError
end