Last Updated: February 25, 2016
·
2.142K
· usmanali

Pretty format for JSON output in Ruby on Rails

require 'json'
my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" }
puts JSON.pretty_generate(my_json)