Skip to content

Instantly share code, notes, and snippets.

@jsvd
Created January 28, 2013 15:42
Show Gist options
  • Select an option

  • Save jsvd/4656564 to your computer and use it in GitHub Desktop.

Select an option

Save jsvd/4656564 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'json'
def jsonpp line
data = JSON.parse(line)
puts JSON.pretty_generate(data)
end
if STDIN.tty?
ARGV.each do |file|
IO.readlines(file).each { |line| jsonpp(line) }
end
else
STDIN.each_line { |line| jsonpp(line) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment