Module: ActiveSupport::JSON::Backends::Yaml

Extended by:
Yaml
Included in:
Yaml
Defined in:
lib/active_support/json/backends/yaml.rb

Constant Summary collapse

ParseError =
::StandardError
EXCEPTIONS =

:nodoc:

[::ArgumentError]

Instance Method Summary collapse

Instance Method Details

#decode(json) ⇒ Object

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



18
19
20
21
22
23
24
25
# File 'lib/active_support/json/backends/yaml.rb', line 18

def decode(json)
  if json.respond_to?(:read)
    json = json.read
  end
  YAML.load(convert_json_to_yaml(json))
rescue *EXCEPTIONS => e
  raise ParseError, "Invalid JSON string: '%s'" % json
end