Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(85728)

Unified Diff: Doc/library/json.rst

Issue 16333: Trailing whitespace in json dump when using indent
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/json/tool.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Doc/library/json.rst Wed Nov 28 02:47:45 2012 -0800
+++ b/Doc/library/json.rst Wed Nov 28 17:59:08 2012 +0200
@@ -42,7 +42,8 @@
Pretty printing::
>>> import json
- >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))
+ >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True,
+ ... indent=4, separators=(',', ': ')))
{
"4": 5,
"6": 7
@@ -155,6 +156,11 @@
.. versionchanged:: 3.2
Allow strings for *indent* in addition to integers.
+ .. note::
+
+ Use ``separators=(',', ': ')`` instead the default *separators* to supress
+ an extra space preciding the newline.
+
If *separators* is an ``(item_separator, dict_separator)`` tuple, then it
will be used instead of the default ``(', ', ': ')`` separators. ``(',',
':')`` is the most compact JSON representation.
@@ -393,6 +399,11 @@
.. versionchanged:: 3.2
Allow strings for *indent* in addition to integers.
+ .. note::
+
+ Use ``separators=(',', ': ')`` instead the default *separators* to supress
+ an extra space preciding the newline.
+
If specified, *separators* should be an ``(item_separator, key_separator)``
tuple. The default is ``(', ', ': ')``. To get the most compact JSON
representation, you should specify ``(',', ':')`` to eliminate whitespace.
« no previous file with comments | « no previous file | Lib/json/tool.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+