Created
May 25, 2015 23:01
-
-
Save jmealo/78031e38cb94830ef400 to your computer and use it in GitHub Desktop.
JSON prettifier for the terminal, just pipe to stdin and it'll output formatted 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 node | |
var stdin = process.openStdin(); | |
var data = ""; | |
stdin.on('data', function(chunk) { | |
data += chunk; | |
}); | |
stdin.on('end', function() { | |
var json; | |
try { | |
json = JSON.parse(data); | |
} catch (e) { | |
console.error(e); | |
process.exit(1); | |
} | |
console.log(JSON.stringify(json, null, ' ')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment