aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/activesupport.gemspec2
-rw-r--r--activesupport/lib/active_support/json/decoding.rb20
2 files changed, 18 insertions, 4 deletions
diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec
index 696f2ca803..e6fc7bf571 100644
--- a/activesupport/activesupport.gemspec
+++ b/activesupport/activesupport.gemspec
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
s.rdoc_options.concat ['--encoding', 'UTF-8']
s.add_dependency('i18n', '~> 0.6')
- s.add_dependency('multi_json', '>= 1.0', '< 1.3')
+ s.add_dependency('multi_json', '~> 1.0')
end
diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb
index cbeb6c0a28..f95eb7a289 100644
--- a/activesupport/lib/active_support/json/decoding.rb
+++ b/activesupport/lib/active_support/json/decoding.rb
@@ -9,7 +9,13 @@ module ActiveSupport
module JSON
class << self
def decode(json, options ={})
- data = MultiJson.decode(json, options)
+ # Can't reliably detect whether MultiJson responds to load, since it's
+ # a reserved word. Use adapter as a proxy for new features.
+ data = if MultiJson.respond_to?(:adapter)
+ MultiJson.load(json, options)
+ else
+ MultiJson.decode(json, options)
+ end
if ActiveSupport.parse_json_times
convert_dates_from(data)
else
@@ -18,12 +24,20 @@ module ActiveSupport
end
def engine
- MultiJson.engine
+ if MultiJson.respond_to?(:adapter)
+ MultiJson.adapter
+ else
+ MultiJson.engine
+ end
end
alias :backend :engine
def engine=(name)
- MultiJson.engine = name
+ if MultiJson.respond_to?(:use)
+ MultiJson.use name
+ else
+ MultiJson.engine = name
+ end
end
alias :backend= :engine=