Skip to content

Commit

Permalink
[FIX] Fix Activesupport json encode for hash
Browse files Browse the repository at this point in the history
  • Loading branch information
manishElitmus committed Dec 30, 2023
1 parent 590a675 commit 94a4adb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/json/encoding.rb
Expand Up @@ -76,7 +76,7 @@ def jsonify(value)
when Hash
result = {}
value.each do |k, v|
k = k.to_s unless Symbol === k || String === k
k = k.to_s unless String === k
result[k] = jsonify(v)
end
result
Expand Down
3 changes: 2 additions & 1 deletion activesupport/test/json/encoding_test_cases.rb
Expand Up @@ -81,7 +81,8 @@ module EncodingTestCases
[ [1, "a", :b, nil, false], %([1,\"a\",\"b\",null,false]) ]]

HashTests = [[ { foo: "bar" }, %({\"foo\":\"bar\"}) ],
[ { 1 => 1, 2 => "a", 3 => :b, 4 => nil, 5 => false }, %({\"1\":1,\"2\":\"a\",\"3\":\"b\",\"4\":null,\"5\":false}) ]]
[ { 1 => 1, 2 => "a", 3 => :b, 4 => nil, 5 => false }, %({\"1\":1,\"2\":\"a\",\"3\":\"b\",\"4\":null,\"5\":false}) ],
[ { "a" => 1, :a => 2, :c => { "b" => 3, :b => 4 } }, %({\"a\":2,\"c\":{\"b\":4}}) ]]

RangeTests = [[ 1..2, %("1..2")],
[ 1...2, %("1...2")],
Expand Down

0 comments on commit 94a4adb

Please sign in to comment.