Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 26 lines (25 sloc) 0.513 kb
#!/usr/bin/env ruby
# Usage: a json FILENAME
# Summary: pretty-print JSON read from STDIN or one or more files
# Help: Simple formatting of JSON content.
#
# EXAMPLES
#
# Format a single file:
#
# a json my_file.json
#
# Format multiple files:
#
# a json file1.json file2.json
#
# Format from STDIN:
#
# curl http://api.com/content.json | a json
#
require 'json'
begin
puts JSON.pretty_generate(JSON.parse(ARGF.read))
rescue JSON::ParserError
abort 'Input could not be parsed as valid JSON.'
end
Jump to Line
Something went wrong with that request. Please try again.