On Sat, Oct 13, 2012 at 5:40 PM, Leo <sdl....@gmail.com> wrote:
> Use this script on a json file and observe all the trailing spaces
> generated. (screenshot attached.)

Confirmed as still the case in Python 3 (specifically, with an early
alpha of 3.3 and with 3.2 for Windows). It's because the item
separator is '; ' and the newline and indent are appended to that.
That can be overridden with:

json.dumps({"asdf":"123","qwer":"234","zxcv":"345"},indent=4,separators=(',',':
'))

but that compacts everything, not sure if that's what you want.

The code in question is in Lib/json/encoder.py in the source tree; I'm
sure you could post on the tracker (hint) with a patch (hint hint) if
you want it to strip spaces followed by newlines.

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to