This project is archived and is in readonly mode.
ActiveSupport::JSON parses dates
Reported by Adam Hooper | May 4th, 2009 @ 07:42 PM | in 2.x
h = { 'd' => '2009-05-04' } => {"d"=>"2009-05-04"} >> ActiveSupport::JSON.decode(h.to_json) => {"d"=>Mon, 04 May 2009}
The expected result, of course, is that h == ActiveSupport::JSON.decode(h.to_json).
JSON does not support dates. Sure, one could say that sucks. But it's not half as sucky as ActiveSupport::JSON's invalid support of String :).
We should either:
- Call Rails's interchange format "ASJSON" or something else which makes it obvious we do not conform to the JSON specification; or
- Conform to the JSON specification.
Comments and changes to this ticket
-
Levin Alexander June 24th, 2009 @ 11:11 PM
This is especially bad if the Dates-strings are invalid:
>> ActiveSupport::JSON.decode('{"date":"2009-01-01"}') => {"date"=>Do, 01 Jan 2009} >> ActiveSupport::JSON.decode('{"date":"0000-00-00"}') ActiveSupport::JSON::ParseError: Invalid JSON string >> JSON.load('{"date":"0000-00-00"}') => {"date"=>"0000-00-00"}
-
Santiago Pastorino April 12th, 2010 @ 01:02 AM
- State changed from new to duplicate
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>