ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
209 stars 51 forks source link

iso8601 dates break on 0.4.0 #68

Closed paulsc closed 6 years ago

paulsc commented 9 years ago

Hi,

After upgrading to 0.4.0, my dates are formated in json as "2014-12-10 17:04:01 UTC" instead of "2014-12-10T17:04:01.678Z" (iso8601) like it is on 0.3.4.

It seems an object of type JSON::Ext::Generator::State is being passed to to_json which makes the date be outputted in that format.

Any idea how to fix ?

Thanks

ccocchi commented 9 years ago

What JSON engine are you using? By default, rabl-rails uses Oj with default options that can be found here https://github.com/ccocchi/rabl-rails/blob/master/lib/rabl-rails.rb#L22.

If you want another date format, you can change these Oj default options in a initializer. Oj options can be found here http://www.rubydoc.info/gems/oj/Oj#default_options-class_method