[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-09 Thread Berker Peksag
Berker Peksag added the comment: Thanks for the reviews. -- resolution: -> fixed stage: commit review -> resolved status: open -> closed ___ Python tracker ___ _

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset 58a871227e5b by Berker Peksag in branch 'default': Issue #21650: Add an `--sort-keys` option to json.tool CLI. https://hg.python.org/cpython/rev/58a871227e5b -- nosy: +python-dev ___ Python tracker

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-05 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> berker.peksag ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: The patch looks good. One nit, the phrase "sorted by their key" has an odd ring to it and is mildly confusing, though technically correct. Perhaps, "sorted alphabetically by key" would be better for most folks. --

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM. -- stage: patch review -> commit review ___ Python tracker ___ ___ Python-bugs-list mailing

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-03 Thread Berker Peksag
Changes by Berker Peksag : Added file: http://bugs.python.org/file37119/issue21650_v4.diff ___ Python tracker ___ ___ Python-bugs-list mailing

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-02 Thread Berker Peksag
Berker Peksag added the comment: Thanks for the suggestions. > If you mean preserve order by default, then yes that would be a nice default. issue21650_v3.diff implements this idea. -- Added file: http://bugs.python.org/file37110/issue21650_v3.diff

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Maybe make sorting keys not default? If you mean preserve order by default, then yes that would be a nice default. -- ___ Python tracker _

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: May be make sorting keys not default? -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: To me, "--unsorted" implies arbitrary ordering such as the order generated by regular dictionaries. I think the option should be "--order-preserving" or some such. The option name needs to make it clear that the output is in the same order an the input.

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-10-26 Thread Martin Panter
Changes by Martin Panter : -- nosy: +vadmium ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-14 Thread Berker Peksag
Berker Peksag added the comment: Updated patch attached based on feedback from David. Thanks! -- stage: needs patch -> patch review Added file: http://bugs.python.org/file35631/issue21650_v2.diff ___ Python tracker

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-06 Thread R. David Murray
R. David Murray added the comment: Wait, I read the code wrong. You can define object_pairs_hook, and use that to return an OrderedDict. So it should be possible to do this without changing the json module itself. This is actually documented as a place to use OrderedDict. Guess I should hav

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-06 Thread R. David Murray
R. David Murray added the comment: Yes but the input is turned into a dict, and dicts do not preserve order. Further, what is passed to the object_hook is already a dict, so the order is already lost before object_hook is called. Since the parser (or at least the Python version of the parser)

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-06 Thread Pavel Kazlou
Pavel Kazlou added the comment: The idea is to keep the same order as in input. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-05 Thread R. David Murray
R. David Murray added the comment: Or does the data get decoded to a dict *before* it gets passed to the object_hook? Probably, in which case nevermind... -- ___ Python tracker ___

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-05 Thread R. David Murray
R. David Murray added the comment: It should be possible to also change the tool to use OrderDicts, though. -- nosy: +r.david.murray ___ Python tracker ___ __

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't really understand the point of this. The "unsorted" output order will be unpredictable for the user (it isn't necessarily the same as the order of fields in the input data). -- nosy: +ezio.melotti, pitrou, rhettinger __

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-03 Thread Berker Peksag
Berker Peksag added the comment: Here's a patch with a test case. -- keywords: +patch nosy: +berker.peksag stage: -> patch review versions: +Python 3.5 -Python 2.7 Added file: http://bugs.python.org/file35468/issue21650.diff ___ Python tracker

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-03 Thread Pavel Kazlou
Pavel Kazlou added the comment: This is the line in module I'm talking about: json.dump(obj, outfile, sort_keys=True, indent=4) -- ___ Python tracker ___

[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-06-03 Thread Pavel Kazlou
New submission from Pavel Kazlou: Currently when you use json.tool, fields are reordered alphabetically. In source code the value of sort_keys is hardcoded to be true. It should be easy to expose this option as command line parameter. -- components: Library (Lib) messages: 219675 nosy: P