[issue16333] Trailing whitespace in json dump when using indent

Zach Mathew report at bugs.python.org
Fri Oct 26 23:25:12 CEST 2012


New submission from Zach Mathew:

When using the indent option in json.JSONEncoder, extra trailing whitespace (preceding the newline) is added to list and dict items.

For example:

>>> import json
>>> json.dumps(['foo', 'bar'], indent=1)
'[\n "foo", \n "bar"\n]'

Notice the blank space between "foo", and \n

EXPECTED OUTPUT:

'[\n "foo",\n "bar"\n]'

----------
components: Library (Lib)
files: fix_json_trailing_space_and_tests.patch
keywords: patch
messages: 173891
nosy: zmathew
priority: normal
severity: normal
status: open
title: Trailing whitespace in json dump when using indent
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file27735/fix_json_trailing_space_and_tests.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16333>
_______________________________________


More information about the Python-bugs-list mailing list