Browse Source

#16476: Fix json.tool to avoid including trailing whitespace.

pull/2332/head
Ezio Melotti 14 years ago
parent
commit
b32512ed9a
  1. 3
      Lib/json/tool.py
  2. 16
      Lib/test/json_tests/test_tool.py
  3. 2
      Misc/NEWS

3
Lib/json/tool.py

@ -31,7 +31,8 @@ def main():
except ValueError as e:
raise SystemExit(e)
with outfile:
json.dump(obj, outfile, sort_keys=True, indent=4)
json.dump(obj, outfile, sort_keys=True,
indent=4, separators=(',', ': '))
outfile.write('\n')

16
Lib/test/json_tests/test_tool.py

@ -19,19 +19,19 @@ class TestTool(unittest.TestCase):
[
[
"blorpie"
],
],
[
"whoops"
],
[],
"d-shtaeou",
"d-nthiouh",
"i-vhbjkhnth",
],
[],
"d-shtaeou",
"d-nthiouh",
"i-vhbjkhnth",
{
"nifty": 87
},
},
{
"field": "yes",
"field": "yes",
"morefield": false
}
]

2
Misc/NEWS

@ -167,6 +167,8 @@ Core and Builtins
Library
-------
- Issue #16476: Fix json.tool to avoid including trailing whitespace.
- Issue #16549: Make json.tool work again on Python 3 and add tests.
Initial patch by Berker Peksag and Serhiy Storchaka.

Loading…
Cancel
Save