Created
December 5, 2013 11:42
-
-
Save coffeeaddict/7803971 to your computer and use it in GitHub Desktop.
Pretty print (and validate) json
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 | |
# | |
# 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