django-prettyjson
django-prettyjson copied to clipboard
Feature idea/request: sort keys alphabetically
I've been integrating with django-prettyjson and in some of my fields the ability to auto sort by key alphabetically in the parsed ("pretty") view would make it even prettier.
- Was this considered?
- Would you be open to a PR with a new class that inherit PrettyJson and adds the alphabetic sort?
Thanks for the great library :)
@kevinmickey wdyt?
I can certainly understand the desire for alphabetically sorting keys. Perhaps as an option, in case the JSON is very large or other reasons you may not want to sort, but I'd be open to "sorted" being the default value for the option.
In terms of implementing this, I would think you could fork yesmeck/jquery-jsonview to add the option and I would certainly be open to point our dependency to the forked version (notably it is unmaintained, so we are free to use our own fork without a PR being accepted upstream).
Let me know if this makes sense to you, or if you feel there are benefits to making more of the modifications in python.
@kevinmickey thanks for the response. Just to make sure I understand what you're saying -
- To add alphabetical sorting I'll need to change the way JS that handles actually showing the widget.
- This is the unmaintained project - https://github.com/yesmeck/jquery-jsonview/
- Which is (minimized) and hardcoded in- https://github.com/kevinmickey/django-prettyjson/blob/b0dedc7a33228b75f31bcf62c5c283c32d136cf9/prettyjson/static/prettyjson/prettyjson.js
Your suggestion is for me to fork the above project, add alphabetical ordering to it, compile and minimize it and open a PR to replace the blob in prettyjson.js with my code?
Yes, you got it -- we are on the same page. For your step 3, there are several options, but I think your proposal (minimizing and hardcoding in, as we currently do) would be the quickest. To be clear, though, the meat of this task is in editing the jquery-jsonview fork.