aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/json/encoding_test.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2009-01-16 17:37:36 +1300
committerMichael Koziarski <michael@koziarski.com>2009-01-16 17:40:04 +1300
commit0bed5bdb213ea68e2f167ac4f61f698f37cf2d69 (patch)
treef8eda6d1671fd9ccf6bd86c56b42f364c6246e80 /activesupport/test/json/encoding_test.rb
parenta53ad5bba37199047ba20194933e122bf6b0252f (diff)
downloadrails-0bed5bdb213ea68e2f167ac4f61f698f37cf2d69.tar.gz
rails-0bed5bdb213ea68e2f167ac4f61f698f37cf2d69.tar.bz2
rails-0bed5bdb213ea68e2f167ac4f61f698f37cf2d69.zip
Properly quote json keys.
According to the RFC and the json.org site all json keys must be strings, and those strings must be quoted with double quotes. [#1755 state:committed]
Diffstat (limited to 'activesupport/test/json/encoding_test.rb')
-rw-r--r--activesupport/test/json/encoding_test.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index 8ed21cc9ad..2c5b4d0378 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -59,7 +59,7 @@ class TestJSONEncoding < Test::Unit::TestCase
assert_equal %({\"a\": \"b\"}), { :a => :b }.to_json
assert_equal %({\"a\": 1}), { 'a' => 1 }.to_json
assert_equal %({\"a\": [1, 2]}), { 'a' => [1,2] }.to_json
- assert_equal %({1: 2}), { 1 => 2 }.to_json
+ assert_equal %({"1": 2}), { 1 => 2 }.to_json
sorted_json = '{' + {:a => :b, :c => :d}.to_json[1..-2].split(', ').sort.join(', ') + '}'
assert_equal %({\"a\": \"b\", \"c\": \"d\"}), sorted_json
@@ -80,7 +80,7 @@ class TestJSONEncoding < Test::Unit::TestCase
def test_hash_key_identifiers_are_always_quoted
values = {0 => 0, 1 => 1, :_ => :_, "$" => "$", "a" => "a", :A => :A, :A0 => :A0, "A0B" => "A0B"}
- assert_equal %w( "$" "A" "A0" "A0B" "_" "a" 0 1 ), object_keys(values.to_json)
+ assert_equal %w( "$" "A" "A0" "A0B" "_" "a" "0" "1" ).sort, object_keys(values.to_json)
end
def test_hash_should_allow_key_filtering_with_only