Changeset 391 for python/trunk/Lib/json/tool.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/json/tool.py
r2 r391 3 3 Usage:: 4 4 5 $ echo '{"json":"obj"}' | python -m json.tool5 $ echo '{"json":"obj"}' | python -m json.tool 6 6 { 7 7 "json": "obj" 8 8 } 9 $ echo '{ 1.2:3.4}' | python -m json.tool10 Expecting property name : line 1 column 2(char 2)9 $ echo '{ 1.2:3.4}' | python -m json.tool 10 Expecting property name enclosed in double quotes: line 1 column 3 (char 2) 11 11 12 12 """ … … 25 25 outfile = open(sys.argv[2], 'wb') 26 26 else: 27 raise SystemExit("{0} [infile [outfile]]".format(sys.argv[0])) 28 try: 29 obj = json.load(infile) 30 except ValueError, e: 31 raise SystemExit(e) 32 json.dump(obj, outfile, sort_keys=True, indent=4) 33 outfile.write('\n') 27 raise SystemExit(sys.argv[0] + " [infile [outfile]]") 28 with infile: 29 try: 30 obj = json.load(infile) 31 except ValueError, e: 32 raise SystemExit(e) 33 with outfile: 34 json.dump(obj, outfile, sort_keys=True, 35 indent=4, separators=(',', ': ')) 36 outfile.write('\n') 34 37 35 38
Note:
See TracChangeset
for help on using the changeset viewer.