diff options
author | Michael Koziarski <michael@koziarski.com> | 2009-01-16 17:37:36 +1300 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-01-16 17:40:04 +1300 |
commit | 0bed5bdb213ea68e2f167ac4f61f698f37cf2d69 (patch) | |
tree | f8eda6d1671fd9ccf6bd86c56b42f364c6246e80 /activesupport/lib/active_support/json | |
parent | a53ad5bba37199047ba20194933e122bf6b0252f (diff) | |
download | rails-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/lib/active_support/json')
-rw-r--r-- | activesupport/lib/active_support/json/encoders/hash.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/json/encoders/hash.rb b/activesupport/lib/active_support/json/encoders/hash.rb index b9bdd55fa5..16dc8337f5 100644 --- a/activesupport/lib/active_support/json/encoders/hash.rb +++ b/activesupport/lib/active_support/json/encoders/hash.rb @@ -5,7 +5,7 @@ class Hash # the hash keys. For example: # # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json - # # => {"name": "Konata Izumi", 1: 2, "age": 16} + # # => {"name": "Konata Izumi", "1": 2, "age": 16} # # The keys in the JSON string are unordered due to the nature of hashes. # @@ -39,7 +39,7 @@ class Hash returning result = '{' do result << hash_keys.map do |key| - "#{ActiveSupport::JSON.encode(key)}: #{ActiveSupport::JSON.encode(self[key], options)}" + "#{ActiveSupport::JSON.encode(key.to_s)}: #{ActiveSupport::JSON.encode(self[key], options)}" end * ', ' result << '}' end |