Mercurial > hg > config
annotate python/jsonex.py @ 564:047a53a8fbad
py3
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Thu, 19 Dec 2013 18:03:05 -0800 |
| parents | cea81044578e |
| children | e50a95358db3 |
| rev | line source |
|---|---|
| 134 | 1 #!/usr/bin/env python |
| 2 | |
| 3 """ | |
| 4 JSON explorer | |
| 5 """ | |
| 6 | |
| 7 import json | |
| 8 import sys | |
| 9 from pprint import pprint | |
| 10 | |
| 11 def main(args=sys.argv[1:]): | |
| 12 data = sys.stdin.read() # read from stdin | |
| 13 obj = json.loads(data) | |
| 14 | |
| 15 if args: | |
| 16 for arg in args: | |
| 17 foo = arg.split('.') # split into objects | |
| 18 # TODO: split into slice notation | |
| 19 pass # TODO | |
| 20 else: | |
| 21 print json.dumps(obj, indent=2, sort_keys=True) | |
| 22 | |
| 23 if __name__ == '__main__': | |
| 24 main() |
