diff options
author | Bob Ippolito <bob@redivi.com> | 2013-02-22 11:25:51 -0800 |
---|---|---|
committer | Bob Ippolito <bob@redivi.com> | 2013-02-22 11:25:51 -0800 |
commit | afa4fd25ca037c3ba4bb35aa99643715e1188ee0 (patch) | |
tree | 93c122e2516f0e496413786e355c4cf9d0aed26f /index.rst | |
parent | 062aa98fe19c9536b6ede4c0b84f5f3e6711b768 (diff) | |
download | simplejson-afa4fd25ca037c3ba4bb35aa99643715e1188ee0.tar.gz |
Updated documentation to reflect separators behavior when indent is not None (#59)
Diffstat (limited to 'index.rst')
-rw-r--r-- | index.rst | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -48,8 +48,7 @@ Compact encoding:: Pretty printing:: >>> import simplejson as json - >>> s = json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4 * ' ') - >>> print('\n'.join([l.rstrip() for l in s.splitlines()])) + >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4 * ' ')) { "4": 5, "6": 7 @@ -167,9 +166,13 @@ Basic Usage .. versionchanged:: 2.1.0 Changed *indent* from an integer number of spaces to a string. - If specified, *separators* should be an ``(item_separator, dict_separator)`` - tuple. By default, ``(', ', ': ')`` are used. 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. + + .. versionchanged:: 2.1.4 + Use ``(',', ': ')`` as default if *indent* is not ``None``. *encoding* is the character encoding for str instances, default is ``'utf-8'``. @@ -527,8 +530,14 @@ Encoders and decoders Changed *indent* from an integer number of spaces to a string. If specified, *separators* should be an ``(item_separator, key_separator)`` - tuple. By default, ``(', ', ': ')`` are used. To get the most compact JSON + tuple. The default is ``(', ', ': ')``. To get the most compact JSON representation, you should specify ``(',', ':')`` to eliminate whitespace. + tuple. The default is ``(', ', ': ')`` if *indent* is ``None`` and + ``(',', ': ')`` otherwise. To get the most compact JSON representation, + you should specify ``(',', ':')`` to eliminate whitespace. + + .. versionchanged:: 2.1.4 + Use ``(',', ': ')`` as default if *indent* is not ``None``. If specified, *default* should be a function that gets called for objects that can't otherwise be serialized. It should return a JSON encodable |