This project is archived and is in readonly mode.

#2632 ✓stale
Neeraj Singh

Adding indent option to to_json method in Hash

Reported by Neeraj Singh | May 11th, 2009 @ 04:04 AM | in 3.x

By default the to_json output of a model is shown in a single line like this .

Sometimes it is better to see the whole JSON output without horizontal scrolling like this .

Attached is a patch that add another option to to_json method of HASH.

Usage. @user.to_json(:indent => 7)

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