A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-October/122152.html below:

[Python-Dev] [BUG] Trailing spaces in pretty-printed JSON

[Python-Dev] [BUG] Trailing spaces in pretty-printed JSONChris Angelico rosuav at gmail.com
Sat Oct 13 20:08:31 CEST 2012
On Sat, Oct 13, 2012 at 5:40 PM, Leo <sdl.web at 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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4