Skip to content

Instantly share code, notes, and snippets.

@coffeeaddict
Created December 5, 2013 11:42
Show Gist options
  • 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 <[email protected]>
#
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