Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
irb(main):006:0> puts ({created_at: Time.now}).to_json
{"created_at":"2014-07-09T06:20:34.167-07:00"}
irb(main):007:0> puts JSON.pretty_generate({created_at: Time.now})
{
"created_at": "2015-04-16 20:36:24 -0700"
}
@johnrees

This comment has been minimized.

Copy link

johnrees commented Feb 25, 2016

did you find out what was causing this? I got here from http://stackoverflow.com/questions/86653/how-can-i-pretty-format-my-json-output-in-ruby-on-rails#comment47516432_23018176

>> puts ({created_at: Time.now}).to_json
{"created_at":"2016-02-25T14:25:41+00:00"}

>> puts JSON.pretty_generate({created_at: Time.now})
{
  "created_at" : "2016-02-25T14:25:42+00:00"
}
@ConorSheehan1

This comment has been minimized.

Copy link

ConorSheehan1 commented Oct 1, 2018

@johnrees it's ActiveSupport's redefinition of to_json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.