Created
November 3, 2010 14:27
-
-
Save sifu/661132 to your computer and use it in GitHub Desktop.
jsoneval
This file contains hidden or 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( ); | |
stdin.setEncoding( 'utf8' ); | |
var chunks = ''; | |
stdin.on( 'data', function ( chunk ) { | |
chunks += chunk.toString( 'utf8' ); | |
} ); | |
stdin.on('end', function () { | |
var body = JSON.parse( chunks ); | |
eval( process.argv[ 2 ] ); | |
} ); |
This file contains hidden or 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
eg. to print the ids of all documents within a couchdb database: | |
curl "http://127.0.0.1:5984/somedb/_all_docs" | jsoneval.js "body.rows.forEach( function( r ){ console.info( r.id ) } );" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you! nice idea, but if i just want to pretty-print something i just pipe it through:
"python -mjson.tool"
which i aliased to pp