Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Basic Usage
a string (such as ``"\t"``) is used to indent each level.
If zero, negative, or ``""`` (the empty string),
only newlines are inserted.
If ``None`` (the default), the most compact representation is used.
If ``None`` (the default), no newlines are inserted.
:type indent: int | str | None

:param separators:
Expand Down
8 changes: 4 additions & 4 deletions Lib/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True,

If ``indent`` is a non-negative integer, then JSON array elements and
object members will be pretty-printed with that indent level. An indent
level of 0 will only insert newlines. ``None`` is the most compact
representation.
level of 0 will only insert newlines. ``None`` gives a compact
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ``indent`` is ``None`` (the default), no newlines are inserted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true. indent=None does not give a compact representation. indent=None gives the result of the same size as indent=0. I would not mention compactness here, it is misleading.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does give a compact representation.

> python -c "print(__import__('json').dumps([{'a': 1, 'b': [2, 3], 'c': {'d': 4, 'e': [5, 6]}}, 7]))"
[{"a": 1, "b": [2, 3], "c": {"d": 4, "e": [5, 6]}}, 7]
> python -c "print(__import__('json').dumps([{'a': 1, 'b': [2, 3], 'c': {'d': 4, 'e': [5, 6]}}, 7], indent=None))"
[{"a": 1, "b": [2, 3], "c": {"d": 4, "e": [5, 6]}}, 7]
> python -c "print(__import__('json').dumps([{'a': 1, 'b': [2, 3], 'c': {'d': 4, 'e': [5, 6]}}, 7], indent=0))"
[
{
"a": 1,
"b": [
2,
3
],
"c": {
"d": 4,
"e": [
5,
6
]
}
},
7
]

representation; see below.

If specified, ``separators`` should be an ``(item_separator,
key_separator)`` tuple. The default is ``(', ', ': ')`` if *indent* is
Expand Down Expand Up @@ -206,8 +206,8 @@ def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,

If ``indent`` is a non-negative integer, then JSON array elements and
object members will be pretty-printed with that indent level. An indent
level of 0 will only insert newlines. ``None`` is the most compact
representation.
level of 0 will only insert newlines. ``None`` gives a compact
representation; see below.

If specified, ``separators`` should be an ``(item_separator,
key_separator)`` tuple. The default is ``(', ', ': ')`` if *indent* is
Expand Down
Loading