diff options
-rw-r--r-- | CHANGES.txt | 6 | ||||
-rw-r--r-- | conf.py | 2 | ||||
-rw-r--r-- | index.rst | 21 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | simplejson/__init__.py | 19 | ||||
-rw-r--r-- | simplejson/encoder.py | 7 |
6 files changed, 37 insertions, 20 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index a9fc019..280d959 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +Version 3.1.2 released XXXX-XX-XX + +* Updated documentation to reflect separators behavior when indent is + not None + https://github.com/simplejson/simplejson/issues/59 + Version 3.1.1 released 2013-02-21 * setup.py now has another workaround for Windows machines without @@ -44,7 +44,7 @@ copyright = '2013, Bob Ippolito' # The short X.Y version. version = '3.1' # The full version, including alpha/beta/rc tags. -release = '3.1.1' +release = '3.1.2' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -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 @@ -8,7 +8,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \ DistutilsPlatformError IS_PYPY = hasattr(sys, 'pypy_translation_info') -VERSION = '3.1.1' +VERSION = '3.1.2' DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" with open('README.rst', 'r') as f: diff --git a/simplejson/__init__.py b/simplejson/__init__.py index 9825a97..d3435f2 100644 --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -38,8 +38,7 @@ Compact encoding:: Pretty printing:: >>> import simplejson as json - >>> s = json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=' ') - >>> print('\n'.join([l.rstrip() for l in s.splitlines()])) + >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=' ')) { "4": 5, "6": 7 @@ -99,7 +98,7 @@ Using simplejson.tool from the shell to validate and pretty-print:: Expecting property name: line 1 column 3 (char 2) """ from __future__ import absolute_import -__version__ = '3.1.1' +__version__ = '3.1.2' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', @@ -180,9 +179,10 @@ def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, versions of simplejson earlier than 2.1.0, an integer is also accepted and is converted to a string with that many spaces. - 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. + 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. ``encoding`` is the character encoding for str instances, default is UTF-8. @@ -277,9 +277,10 @@ def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, versions of simplejson earlier than 2.1.0, an integer is also accepted and is converted to a string with that many spaces. - 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. + 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. ``encoding`` is the character encoding for str instances, default is UTF-8. diff --git a/simplejson/encoder.py b/simplejson/encoder.py index db5c946..213fefb 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -153,9 +153,10 @@ class JSONEncoder(object): versions of simplejson earlier than 2.1.0, an integer is also accepted and is converted to a string with that many spaces. - 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 |