-
-
Save ryankirkman/76a95bb3ac2bb1a4e326 to your computer and use it in GitHub Desktop.
Read JSON from standard input and writes formatted JSON to standard output. Requires Node.js.
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 | |
// Reads JSON from stdin and writes equivalent | |
// nicely-formatted JSON to stdout. | |
var input = ''; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function (chunk) { | |
input += chunk; | |
}); | |
process.stdin.on('end', function () { | |
var parsedData = JSON.parse(input); | |
var outputJSON = JSON.stringify(parsedData, null, ' '); | |
process.stdout.write(outputJSON); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment