ActiveRecord: Produce multi-line human-friendly json
Posted
by
Mika
on Stack Overflow
See other posts from Stack Overflow
or by Mika
Published on 2011-07-10T08:34:57Z
Indexed on
2012/11/03
5:03 UTC
Read the original article
Hit count: 265
Using ActiveRecord::Base.to_json I do:
user = User.find_by_name 'Mika'
{"created_at":"2011-07-10T11:30:49+03:00","id":5,"is_deleted":null,"name":"Mika"}
Now, what I would like to have is:
{
"created_at":"2011-07-10T11:30:49+03:00",
"id":5,
"is_deleted":null,
"name":"Mika"
}
Is there an option to do this?
It would be great to have a global option, so that the behaviour be set depending on dev/live environment.
© Stack Overflow or respective owner