Thanks for idea, sometime this can be helpful

Here is the script in ruby

---------------------------------------------

#!/usr/bin/env ruby -wKU

require 'rubygems'
require 'json'

json = `curl -s #{ARGV}`
puts JSON.pretty_generate(JSON.parse(json))

---------------------------------------------

Two addition,

* It doesn't require pipe curl, still forward Arguments to curl.
* -s option provided by default.

above script can be used as command

Thanks
Niket Patel

On Aug 20, 2008, at 11:34 PM, Jason Huggins wrote:

Here's the script:
--------------------------------------------------------
#! /usr/bin/python

import sys
import simplejson

raw_input = sys.stdin.read()
json_data = simplejson.loads(raw_input)

# Make pretty!
print simplejson.dumps(json_data, sort_keys=True, indent=4)
--------------------------------------------------------

To get this to work correctly, I also had to add the silent "-s" flag
to curl so that it didn't print a progress meter with the results as
well. (Try it without "-s" to see what I mean.)

I would love it there was "pretty print all output" configuration
option for Couch... but until then, I'll just use my script. :-)


Reply via email to