From 17da45b789e0a2581eae6e6b2b1ae8d2b98e0f5d Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 7 Jan 2009 17:51:11 +0000 Subject: Fix JSON decoder date-converter regexp [#1662 state:resolved] [Jonathan del Strother] --- activesupport/lib/active_support/json/decoding.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/json') diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb index fdb219dbf7..9da4048272 100644 --- a/activesupport/lib/active_support/json/decoding.rb +++ b/activesupport/lib/active_support/json/decoding.rb @@ -16,7 +16,7 @@ module ActiveSupport protected # matches YAML-formatted dates - DATE_REGEX = /^\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?$/ + DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?)$/ # Ensure that ":" and "," are always followed by a space def convert_json_to_yaml(json) #:nodoc: -- cgit v1.2.3 From 0bed5bdb213ea68e2f167ac4f61f698f37cf2d69 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Fri, 16 Jan 2009 17:37:36 +1300 Subject: 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] --- activesupport/lib/active_support/json/encoders/hash.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/json') 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 -- cgit v1.2.3 From 39e1ac658efc80e4c54abef4f1c7679e4b3dc2ac Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sun, 18 Jan 2009 18:10:58 +0000 Subject: Merge docrails --- activesupport/lib/active_support/json/encoders/date.rb | 2 +- activesupport/lib/active_support/json/encoders/date_time.rb | 2 +- activesupport/lib/active_support/json/encoders/time.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support/json') diff --git a/activesupport/lib/active_support/json/encoders/date.rb b/activesupport/lib/active_support/json/encoders/date.rb index 1fc99c466f..cc84de1388 100644 --- a/activesupport/lib/active_support/json/encoders/date.rb +++ b/activesupport/lib/active_support/json/encoders/date.rb @@ -2,7 +2,7 @@ class Date # Returns a JSON string representing the date. If ActiveSupport.use_standard_json_time_format is set to true, the # ISO 8601 format is used. # - # ==== Examples: + # ==== Examples # # # With ActiveSupport.use_standard_json_time_format = true # Date.new(2005,2,1).to_json diff --git a/activesupport/lib/active_support/json/encoders/date_time.rb b/activesupport/lib/active_support/json/encoders/date_time.rb index e259930033..6c85824105 100644 --- a/activesupport/lib/active_support/json/encoders/date_time.rb +++ b/activesupport/lib/active_support/json/encoders/date_time.rb @@ -2,7 +2,7 @@ class DateTime # Returns a JSON string representing the datetime. If ActiveSupport.use_standard_json_time_format is set to true, the # ISO 8601 format is used. # - # ==== Examples: + # ==== Examples # # # With ActiveSupport.use_standard_json_time_format = true # DateTime.civil(2005,2,1,15,15,10).to_json diff --git a/activesupport/lib/active_support/json/encoders/time.rb b/activesupport/lib/active_support/json/encoders/time.rb index 09fc614889..f45a0059e8 100644 --- a/activesupport/lib/active_support/json/encoders/time.rb +++ b/activesupport/lib/active_support/json/encoders/time.rb @@ -2,7 +2,7 @@ class Time # Returns a JSON string representing the time. If ActiveSupport.use_standard_json_time_format is set to true, the # ISO 8601 format is used. # - # ==== Examples: + # ==== Examples # # # With ActiveSupport.use_standard_json_time_format = true # Time.utc(2005,2,1,15,15,10).to_json -- cgit v1.2.3