This project is archived and is in readonly mode.

#6544 ✓committed
Sakuro

AS::JSON Yaml backend sometimes do not honor AS:parse_json_times

Reported by Sakuro | March 8th, 2011 @ 04:31 AM | in 3.1

ActiveSupport::VERSION::STRING "3.1.0.beta" (commit: 1408b942d9c2c131a1cdcab97f49d74ce84dae38)

>> ActiveSupport::JSON.backend = 'Yaml'
=> "Yaml"
>> ActiveSupport.parse_json_times = true
=> true
>> ActiveSupport::JSON.decode('{"timestamp":"2011-03-08T13:24:00Z"}')
=> {"timestamp"=>2011-03-08 13:24:00 UTC} #parsed, correct
>> ActiveSupport::JSON.decode('["2011-03-08T13:24:00Z"]')
=> ["2011-03-08T13:24:00Z"] #not parsed, incorrect!
>> ActiveSupport.parse_json_times = false
=> false
>> ActiveSupport::JSON.decode('{"timestamp":"2011-03-08T13:24:00Z"}')
=> {"timestamp"=>2011-03-08 13:24:00 UTC} #parsed, incorrect!
>> ActiveSupport::JSON.decode('["2011-03-08T13:24:00Z"]')
=> ["2011-03-08T13:24:00Z"] #not parsed, correct

FYI, JSONGem backend works correctly.

>> ActiveSupport::JSON.backend = 'JSONGem'
=> "JSONGem"
>> ActiveSupport.parse_json_times = true
=> true
>> ActiveSupport::JSON.decode('{"timestamp":"2011-03-08T13:24:00Z"}')
=> {"timestamp"=>Tue, 08 Mar 2011 13:24:00 +0000} #parsed, correct
>> ActiveSupport::JSON.decode('["2011-03-08T13:24:00Z"]')
=> [Tue, 08 Mar 2011 13:24:00 +0000] #parsed, correct
>> ActiveSupport.parse_json_times = false
=> false
>> ActiveSupport::JSON.decode('{"timestamp":"2011-03-08T13:24:00Z"}')
=> {"timestamp"=>"2011-03-08T13:24:00Z"} #not parsed, correct
>> ActiveSupport::JSON.decode('["2011-03-08T13:24:00Z"]')
=> ["2011-03-08T13:24:00Z"] #not parsed, correct

Comments and changes to this ticket

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>

Attachments

Pages