aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/json/encoder.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/json/encoder.py')
-rw-r--r--Lib/json/encoder.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
index ba57c2c25ee..93b5ea7d5e0 100644
--- a/Lib/json/encoder.py
+++ b/Lib/json/encoder.py
@@ -127,9 +127,10 @@ class JSONEncoder(object):
indent level. An indent level of 0 will only insert newlines.
None is the most compact representation.
- If specified, separators should be a (item_separator, key_separator)
- tuple. The default is (', ', ': '). To get the most compact JSON
- representation you should specify (',', ':') to eliminate whitespace.
+ If specified, separators should be an (item_separator, key_separator)
+ tuple. The default is (', ', ': ') if *indent* is ``None`` and
+ (',', ': ') otherwise. To get the most compact JSON representation,
+ you should specify (',', ':') to eliminate whitespace.
If specified, default is a function that gets called for objects
that can't otherwise be serialized. It should return a JSON encodable
@@ -145,6 +146,8 @@ class JSONEncoder(object):
self.indent = indent
if separators is not None:
self.item_separator, self.key_separator = separators
+ elif indent is not None:
+ self.item_separator = ','
if default is not None:
self.default = default