File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
activesupport/lib/active_support/json Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,11 @@ module JSON
20
20
# # => "{\"team\":\"rails\",\"players\":\"36\"}"
21
21
class << self
22
22
def encode ( value , options = nil )
23
- Encoding . json_encoder . new ( options ) . encode ( value )
23
+ if options . nil?
24
+ Encoding . encode_without_options ( value )
25
+ else
26
+ Encoding . json_encoder . new ( options ) . encode ( value )
27
+ end
24
28
end
25
29
alias_method :dump , :encode
26
30
end
@@ -108,7 +112,16 @@ class << self
108
112
109
113
# Sets the encoder used by \Rails to encode Ruby objects into JSON strings
110
114
# in +Object#to_json+ and +ActiveSupport::JSON.encode+.
111
- attr_accessor :json_encoder
115
+ attr_reader :json_encoder
116
+
117
+ def json_encoder = ( encoder )
118
+ @json_encoder = encoder
119
+ @encoder_without_options = encoder . new
120
+ end
121
+
122
+ def encode_without_options ( value ) # :nodoc:
123
+ @encoder_without_options . encode ( value )
124
+ end
112
125
end
113
126
114
127
self . use_standard_json_time_format = true
You can’t perform that action at this time.
0 commit comments