Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 36 lines (26 sloc) 1.04 KB
#!/usr/bin/env node
/* vim: set filetype=javascript : */
/*
Usage examples:
1. Read stdin
echo '{"name":"Vadim","surname":"Voituk","blog":"http://voituk.kiev.ua/","twitter":"http://twitter.com/voituk","linkedin":"http://www.linkedin.com/in/voituk","location":{"city":"Kiev","country":"Ukraine","latitude":50.4333333,"longitude":30.5166667},"friends":["Juriy Bura","Denis Derevyanchuk","Andrew Danilik","Stelya Igor"]}' \
| ./jsonlint
2. curl "http://search.twitter.com/search.json?q=@voituk" | jsonlint | less
3. curl -s "http://api.twitter.com/1/users/show/voituk.json" | jsonlint | less
*/
var util = require('util');
try {
process.stdin.resume();
process.stdin.setEncoding('utf8');
var input = ''
process.stdin.on('data', function (chunk) {
input += chunk
})
process.stdin.on('end', function () {
//process.stdout.write(JSON.stringify(JSON.parse(input), null, 4) + '\n')
process.stdout.write(util.inspect(JSON.parse(input), true, null, true) + "\n" )
})
} catch (e) {
process.stderr.write(e.stack + "\n")
process.exit(1)
}