We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
json
2.14.0+
1 parent 4c39e96 commit a8a80e3Copy full SHA for a8a80e3
activesupport/lib/active_support/json/encoding.rb
@@ -147,7 +147,13 @@ class JSONGemCoderEncoder # :nodoc:
147
json_value = value.as_json
148
# Handle objects returning self from as_json
149
if json_value.equal?(value)
150
- next ::JSON::Fragment.new(::JSON.generate(json_value))
+ if JSON_NATIVE_TYPES.include?(json_value.class)
151
+ # If the callback is invoked for a native type,
152
+ # it means it is hash keys, e.g. { 1 => true }
153
+ next json_value.to_s
154
+ else
155
+ next ::JSON::Fragment.new(::JSON.generate(json_value))
156
+ end
157
end
158
# Handle objects not returning JSON-native types from as_json
159
count = 5
0 commit comments