Created
December 13, 2012 19:41
-
-
Save hynkle/4279152 to your computer and use it in GitHub Desktop.
Reads JSON from stdin; pretty prints it to stdout.
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 flatJSON = ''; | |
process.stdin.on('data', function(data) { | |
flatJSON = flatJSON + data; | |
}); | |
process.stdin.on('end', function() { | |
prettyJSON = JSON.stringify( JSON.parse(flatJSON), null, 2 ) | |
console.log(prettyJSON); | |
}); | |
process.stdin.resume(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget to
chmod +x ppjson.js