Created
October 15, 2010 16:05
-
-
Save DeMarko/628446 to your computer and use it in GitHub Desktop.
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 | |
# == Synopsis | |
# jsonpretty: a quick script for making JSON output legible | |
# | |
# == Usage | |
# jsonpretty [a JSON encoded file] | |
# [some stream with JSON text] | jsonpretty | |
# | |
# For this help use: jsonpretty -h | |
# | |
# == Author | |
# Dannel Jurado | |
# | |
# == Fun Fact | |
# the RDoc for this script is longer than the script itself | |
# even without this fact! | |
require "rubygems" | |
require "json" | |
require "yaml" | |
require "optparse" | |
require "rdoc/usage" | |
opts = OptionParser.new | |
opts.on('-h', '--help') { RDoc::usage() } | |
opts.parse!(ARGV) | |
jsonfile = ARGV[0].nil? ? $< : File.open(ARGV[0]) | |
puts YAML.dump(JSON.parse(jsonfile.readlines.join)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment