Re: A minor beef with JSON::decode

Aaron Patterson
Wed, 25 Jul 2012 23:32:02 -0000

On Wed, Jul 25, 2012 at 11:09:06AM -0700, Josh Bourgeois
wrote:
> Hiya,
>
> So, what was the impetus behind having ParamsParser create Date and
> DateTime objects out of application/json requests?  The project
I''m on
> expects parameters to be received as standard types (bools, numbers,
> strings, arrays, and hashes).  Rails shouldn''t try to convert
objects that
> are explicitly passed as these types; it should be up to the application to
> do that.

I think this ship has sailed. :-/

However, it looks like you can set ActiveSupport.parse_json_times to
false:


https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/json/decoding.rb#L6-7

And it won''t try to parse dates:


https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/json/decoding.rb#L19-23

--
Aaron Patterson