Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Updated documentation for json.COMPACT
  • Loading branch information
andrewnester committed Feb 16, 2017
commit 32c4b13ad5f456f719708849ab3931b1e349d457
15 changes: 14 additions & 1 deletion Doc/library/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Encoding basic Python object hierarchies::
Compact encoding::

>>> import json
>>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
>>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=json.COMPACT)
'[1,2,3,{"4":5,"6":7}]'

Pretty printing::
Expand Down Expand Up @@ -175,6 +175,9 @@ Basic Usage
.. versionchanged:: 3.4
Use ``(',', ': ')`` as default if *indent* is not ``None``.

.. versionchanged:: 3.7
Instead of ``(',', ':')`` constant :data:`json.COMPACT` can be used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think a versionchanged field is necessary as nothing about the function actually changed. I think it would be better to update the paragraph above from "To get the most compact JSON representation,
you should specify (',', ':') to eliminate whitespace." to "To get the most compact JSON representation,
you should specify :attr:json.COMPACT to eliminate whitespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@brettcannon sounds reasonable! I've just updated it, thanks!


If specified, *default* should be a function that gets called for objects that
can't otherwise be serialized. It should return a JSON encodable version of
the object or raise a :exc:`TypeError`. If not specified, :exc:`TypeError`
Expand Down Expand Up @@ -283,6 +286,16 @@ Basic Usage
input encoding should be UTF-8, UTF-16 or UTF-32.


Constants
^^^^^^^^^

.. data:: compact

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

compact -> COMPACT


A constant that can be used as the *separators* argument to emit a compact serialization.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please wrap lines at 80 chars.


.. versionadded:: 3.7


Encoders and Decoders
---------------------

Expand Down