Skip to content

Instantly share code, notes, and snippets.

@coffeeaddict
Created December 5, 2013 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coffeeaddict/7803971 to your computer and use it in GitHub Desktop.
Save coffeeaddict/7803971 to your computer and use it in GitHub Desktop.
Pretty print (and validate) json
#!/usr/bin/env ruby
#
# Pretty print (and validate) json
#
# usage: curl http://localhost/api/unreadable.json | json_lint
#
# author: Hartog C. de Mik <hartog@organisedminds.com>
#
require 'json'
puts JSON.pretty_generate(JSON.parse($stdin.read)).gsub("{\n", '{').gsub(/\{\s+/, '{ ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment