Issue 10019: json.dumps with indent = 0 not adding newlines (original) (raw)
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}
Hi, I updated the patch, making one for 2.7, 3.1 and 3.2 (this last one applies cleanly on default too).
As of merging simplejson, it's more a matter of porting it to Python 3. I'll drop an email to Bob soon, let's see how it goes.