-
Notifications
You must be signed in to change notification settings - Fork 9
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
Output with consistent key ordering #15
Comments
Passing |
This is to address jonathanstowe/META6#15
This is to address jonathanstowe/META6#15
|
Oh I totally agree, if I was editing the META6 by hand I'd put the However I really can't see a way of making this happening without the support of the thing that actually produces the JSON string. |
See https://gist.github.com/jaguart/bd64157bcfa8271ad5bed69a286e0613 - I'm thinking you could override the .sort method on the hash to get JSON::Fast to produce consistent ordering. Apologies for newbie code - but the concept seems to work... |
FYI: timo/json_fast#83 |
Obviously the majority of the changes would need to be in https://github.com/jonathanstowe/JSON-Class and https://github.com/jonathanstowe/JSON-Marshal and the basic requirement, as I see it, is that a class passed to the |
Every time you call
.to-json
, this class outputs the keys in a different order. It would be very helpful if.to-json
always output the keys in a fixed order, especially for keeping git patches more helpfully concise.In an ideal world, we could all agree on what that order was and it probably wouldn't alphabetical because the most important information is problem name, version, authors, license, source, with depends, resources, and other bits toward the bottom, but even alphabetical order would be better than order by random.
It should be possible to make it alphabetical by passing the
:sorted-keys
option to JSON::Fast, which ultimate performs the serialization. However, that has to go through JSON::Class and JSON::Marshal somehow.The text was updated successfully, but these errors were encountered: