classification
Title: wrong default for sort_keys in json module documentation
Type: behavior Stage: commit review
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, georg.brandl, mdirolf, terry.reedy
Priority: normal Keywords: patch

Created on 2010-08-20 15:43 by mdirolf, last changed 2010-08-22 20:23 by georg.brandl. This issue is now closed.

Files
File name Uploaded Description Edit
sort_keys_json.patch mdirolf, 2010-08-20 15:43
Messages (3)
msg114426 - (view) Author: Mike Dirolf (mdirolf) Date: 2010-08-20 15:43
The json module docs state that sort_keys defaults to True. From the source it looks like it actually defaults to False. Patch attached.
msg114445 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-20 19:56
In 3.1, and I presume (please check) 2.7, the signature is given as
class json.JSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None) 

I verified by simple experiment that keys are not sorted by default. 
So the later claim "If sort_keys is True (the default)" is wrong and should be corrected. The patch or something much like it should be applied. Thanks for catching this error.
msg114700 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-08-22 20:23
Thanks, fixed in r84264.
History
Date User Action Args
2010-08-22 20:23:58georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg114700

resolution: fixed
2010-08-20 19:56:17terry.reedysetversions: + Python 3.1, Python 3.2
nosy: + terry.reedy

messages: + msg114445

type: behavior
stage: commit review
2010-08-20 15:43:14mdirolfcreate