Skip to content

Instantly share code, notes, and snippets.

@georgkreimer
Created August 19, 2010 12:44
Show Gist options
  • Save georgkreimer/537794 to your computer and use it in GitHub Desktop.
Save georgkreimer/537794 to your computer and use it in GitHub Desktop.
pretty print json in ruby
require 'json'
my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" }
puts JSON.pretty_generate(my_json)
Which gets you...
{
"array": [
1,
2,
3,
{
"sample": "hash"
}
],
"foo": "bar"
}
@a2f0
Copy link

a2f0 commented Jul 16, 2019

A+ 🌈💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment