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

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

Constant Summary

ParseError =
::StandardError

Instance Method Summary (collapse)

Instance Method Details

- (Object) decode(json)

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



11
12
13
14
15
16
17
18
# File 'activesupport/lib/active_support/json/backends/yaml.rb', line 11

def decode(json)
  if json.respond_to?(:read)
    json = json.read
  end
  YAML.load(convert_json_to_yaml(json))
rescue ArgumentError
  raise ParseError, "Invalid JSON string"
end