mirror of
https://github.com/python/cpython.git
synced 2025-09-25 01:43:11 +00:00
#16549: Add tests for json.tools. Initial patch by Berker Peksag and Serhiy Storchaka.
This commit is contained in:
parent
67473263a3
commit
d8feba904c
4 changed files with 81 additions and 6 deletions
|
@ -25,12 +25,14 @@ def main():
|
|||
outfile = open(sys.argv[2], 'wb')
|
||||
else:
|
||||
raise SystemExit(sys.argv[0] + " [infile [outfile]]")
|
||||
try:
|
||||
obj = json.load(infile)
|
||||
except ValueError, e:
|
||||
raise SystemExit(e)
|
||||
json.dump(obj, outfile, sort_keys=True, indent=4)
|
||||
outfile.write('\n')
|
||||
with infile:
|
||||
try:
|
||||
obj = json.load(infile)
|
||||
except ValueError, e:
|
||||
raise SystemExit(e)
|
||||
with outfile:
|
||||
json.dump(obj, outfile, sort_keys=True, indent=4)
|
||||
outfile.write('\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue