New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document json "sort_keys" parameter properly #58775
Comments
The json "sort_keys" parameter is actually supported as an argument to dump() and dumps() (and is used that way in the examples), but is only documented as an argument to the JSONEncoder constructor. |
In json module there are dump/dumps methods which internally instantiate encoder class JSONEncoder (or some other user-defined encoder clas). json.dump(obj, fp,
skipkeys=False,
ensure_ascii=True,
check_circular=True,
allow_nan=True,
cls=None,
indent=None,
separators=None,
default=None,
**kw)
json.JSONEncoder(skipkeys=False,
ensure_ascii=True,
check_circular=True,
allow_nan=True,
sort_keys=False,
indent=None,
separators=None,
default=None) Some of dump/dumps arguments are passed to encoder class:
And it looks that sort_keys is just missing in keyword args in dump/dumps method. I would propose to do:
|
Attached a patch. |
Erm, the patch seems to have some ANSI terminal coloring escape code junk (e.g. "�[0;31m") in it... |
Attached updated patches. |
Any reactions? The patch is pretty straightforward... |
I would recommend making the added and modified lines not exceed 79 characters in both files. Also, for the .rst file, you can use slashes to break lines as shown in the following example: http://hg.python.org/cpython/file/09011896374d/Doc/library/argparse.rst#l133 |
Also, while not strictly necessary, it is more customary and convenient to provide a single patch file for all files. |
Per Chris Jerdonek, here's a combined patch that also makes the docs changes comply with the antiquated line length limit. |
New changeset 40aedc7da30f by Andrew Svetlov in branch '3.2': New changeset 090484ccba7d by Andrew Svetlov in branch '3.3': New changeset 27ce005372a5 by Andrew Svetlov in branch 'default': |
Thanks, Chris! |
Patch for 2.7. This assumes that changing the parameter notation is permissible. |
New changeset 7784008e9ade by Andrew Svetlov in branch '2.7': |
Fixed, thanks again! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: