Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveSupport::JSON parses dates

#2605

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:

  1. Call Rails's interchange format "ASJSON" or something else which makes it obvious we do not conform to the JSON specification; or
  2. Conform to the JSON specification.

Reported by Adam Hooper · May 4th, 2009 @ 07:42 PM

State: duplicate
Milestone: 2.x
Assigned to: Ryan Bigg Ryan Bigg
Importance: none

Activity

  1. Levin Alexander
    Levin Alexander

    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"}
    

    June 24th, 2009 @ 11:11 PM

  2. Rishav Rastogi
  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to duplicate

    April 12th, 2010 @ 01:02 AM