aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/json.rb')
-rw-r--r--activesupport/lib/active_support/json.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/json.rb b/activesupport/lib/active_support/json.rb
index 5072992cdf..1e8ded12da 100644
--- a/activesupport/lib/active_support/json.rb
+++ b/activesupport/lib/active_support/json.rb
@@ -40,9 +40,15 @@ module ActiveSupport
end
class << self
- attr_reader :backend
delegate :decode, :to => :backend
-
+
+ def backend
+ @backend || begin
+ self.backend = defined?(::JSON) ? "JSONGem" : "Yaml"
+ @backend
+ end
+ end
+
def backend=(name)
if name.is_a?(Module)
@backend = name
@@ -77,6 +83,5 @@ module ActiveSupport
end
ActiveSupport.escape_html_entities_in_json = true
-ActiveSupport::JSON.backend = 'Yaml'
require 'active_support/json/encoding'