aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/backends/yaml.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/json/backends/yaml.rb')
-rw-r--r--activesupport/lib/active_support/json/backends/yaml.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/json/backends/yaml.rb b/activesupport/lib/active_support/json/backends/yaml.rb
index c7db508c23..1c18fc4801 100644
--- a/activesupport/lib/active_support/json/backends/yaml.rb
+++ b/activesupport/lib/active_support/json/backends/yaml.rb
@@ -9,8 +9,11 @@ module ActiveSupport
module Yaml
extend self
- # Converts a JSON string into a Ruby object.
+ # Parses a JSON string or IO and converts it into an object
def decode(json)
+ if json.respond_to?(:read)
+ json = json.read
+ end
YAML.load(convert_json_to_yaml(json))
rescue ArgumentError => e
raise ParseError, "Invalid JSON string"