Created
May 24, 2013 21:47
-
-
Save benr75/5646723 to your computer and use it in GitHub Desktop.
JSON pretty from commandline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Example usage: | |
# curl https://api.twitter.com/1/statuses/show.json?id=231426135903305728 | jsonviewer.rb | |
# | |
require 'rubygems' | |
require 'awesome_print' | |
require 'json' | |
ap JSON.parse(ARGF.read) | |
# Was going to write to a file and open the file, but awesome_print line breaks didn't get written to file | |
=begin | |
filename = "#{ENV['HOME']}/tmp/#{rand(100000)}.json" | |
File.open(filename, 'w') {|f| f.write(ap JSON.parse(ARGF.read)) } | |
`open #{filename}` | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment