Skip to content

Instantly share code, notes, and snippets.

@hynkle
Created December 13, 2012 19:41
Show Gist options
  • Save hynkle/4279152 to your computer and use it in GitHub Desktop.
Save hynkle/4279152 to your computer and use it in GitHub Desktop.
Reads JSON from stdin; pretty prints it to stdout.
#!/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();
@hynkle
Copy link
Author

hynkle commented Dec 13, 2012

Don't forget to chmod +x ppjson.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment