#16333: document a way to get rid of trailing whitespace when indent is used.
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index e5ef1e7..71020fd 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -43,7 +43,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
@@ -153,6 +154,12 @@
or negative, will only insert newlines. ``None`` (the default) selects the
most compact representation.
+ .. note::
+
+ Since the default item separator is ``', '``, the output might include
+ trailing whitespace when *indent* is specified. You can use
+ ``separators=(',', ': ')`` to avoid this.
+
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.
@@ -410,6 +417,12 @@
level. An indent level of 0 will only insert newlines. ``None`` is the most
compact representation.
+ .. note::
+
+ Since the default item separator is ``', '``, the output might include
+ trailing whitespace when *indent* is specified. You can use
+ ``separators=(',', ': ')`` to avoid this.
+
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.