Skip to content

Commit f010edc

Browse files
committed
Improve Fragment handling in JSON::Encoding
1 parent d2ce0e9 commit f010edc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

actionpack/profile-20250213-085143-11604.vernier.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

activesupport/lib/active_support/json/encoding.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def encode(value)
8585
# to +object.as_json+, not any of this method's recursive +#as_json+
8686
# calls.
8787
def jsonify(value)
88-
return value if value.class.name == "JSON::Fragment"
8988
case value
9089
when String, Integer, Symbol, nil, true, false
9190
value
@@ -101,7 +100,11 @@ def jsonify(value)
101100
when Array
102101
value.map { |v| jsonify(v) }
103102
else
104-
jsonify value.as_json
103+
if defined?(::JSON::Fragment) && ::JSON::Fragment === value
104+
value
105+
else
106+
jsonify value.as_json
107+
end
105108
end
106109
end
107110

0 commit comments

Comments
 (0)