Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5896 from sferik/revert_5861

Revert #5861. Feature-detect which MultiJson API to use.
  • Loading branch information...
commit c3d50b35b0e03a68095ebb0d52d371d28c8aa436 2 parents f51557d + 5e62670
Jeremy Kemper jeremy authored
2  activesupport/activesupport.gemspec
View
@@ -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
20 activesupport/lib/active_support/json/decoding.rb
View
@@ -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 @@ def decode(json, options ={})
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=
Please sign in to comment.
Something went wrong with that request. Please try again.