Latest recipes tagged "node"http://code.activestate.com/recipes/tags/node/new/2011-01-18T22:59:12-08:00ActiveState Code Recipesnicerest: pretty-print JSON output (JavaScript)
2011-01-18T22:59:12-08:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577549-nicerest-pretty-print-json-output/
<p style="color: grey">
JavaScript
recipe 577549
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/curl/">curl</a>, <a href="/recipes/tags/json/">json</a>, <a href="/recipes/tags/node/">node</a>, <a href="/recipes/tags/nodejs/">nodejs</a>, <a href="/recipes/tags/rest/">rest</a>).
Revision 3.
</p>
<p>Save this to "nicerest", <code>chmod +x</code>-it, and pipe your REST API <code>curl</code> calls through this for nicer output. It will notice HTTP headers (curl's <code>-i</code> option) and skips those before attempting to pretty-print the following JSON.</p>
<p>Note: This is currently using node 0.2. I should update for 0.3 changes (I think <code>process.openStdin</code> changed).</p>