aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/backends/yaml.rb
diff options
context:
space:
mode:
authorBrian Lopez <seniorlopez@gmail.com>2009-05-17 10:37:30 -0500
committerJoshua Peek <josh@joshpeek.com>2009-05-17 10:37:52 -0500
commit53dda29f8b34073a4b135ee224c1d09c1f10de02 (patch)
tree4046b55b7609e20c6ef4cc8732724b774b997bf8 /activesupport/lib/active_support/json/backends/yaml.rb
parent344ee681d6a89ea1da71c39e75c29e0cbda44914 (diff)
downloadrails-53dda29f8b34073a4b135ee224c1d09c1f10de02.tar.gz
rails-53dda29f8b34073a4b135ee224c1d09c1f10de02.tar.bz2
rails-53dda29f8b34073a4b135ee224c1d09c1f10de02.zip
Add support for parsing XML and JSON from an IO as well as a string [#2659 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
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"