# HG changeset patch # User Jeff Hammel # Date 1301072309 25200 # Node ID cea81044578ed225d7af35fe6d9083e888821a33 # Parent bd47021b8313907662142fc9681360e97a8824e9 add a JSON explorer diff -r bd47021b8313 -r cea81044578e python/jsonex.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/jsonex.py Fri Mar 25 09:58:29 2011 -0700 @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +""" +JSON explorer +""" + +import json +import sys +from pprint import pprint + +def main(args=sys.argv[1:]): + data = sys.stdin.read() # read from stdin + obj = json.loads(data) + + if args: + for arg in args: + foo = arg.split('.') # split into objects + # TODO: split into slice notation + pass # TODO + else: + print json.dumps(obj, indent=2, sort_keys=True) + +if __name__ == '__main__': + main()