[issue10019] json.dumps with indent = 0 not adding newlines

David Janes report at bugs.python.org
Sun Oct 3 18:22:37 CEST 2010


New submission from David Janes <davidjanes at davidjanes.com>:

In Python 2.6.4, json.dumps(...,indent=0) produced newlines as documented here: http://docs.python.org/library/json.html#json.dump
In Python 2.7, it no longer adds newlines.

$ python
Python 2.6.4 (r264:75706, Jan 13 2010, 19:41:08) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.dumps({3:1,4:2},indent=0)
'{\n"3": 1, \n"4": 2\n}'
>>> print json.dumps({3:1,4:2},indent=0)
{
"3": 1, 
"4": 2
}



$ python
Python 2.7 (r27:82500, Oct  3 2010, 06:00:45) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.dumps({3:1,4:2})
'{"3": 1, "4": 2}'
>>> print json.dumps({3:1,4:2},indent=0)
{"3": 1, "4": 2}

----------
components: Library (Lib)
messages: 117917
nosy: dpjanes
priority: normal
severity: normal
status: open
title: json.dumps with indent = 0 not adding newlines
versions: Python 2.7

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


More information about the Python-bugs-list mailing list