-
Notifications
You must be signed in to change notification settings - Fork 11
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
Option not to sort the keys #47
Comments
Hi, thank you! So I'm guessing you have a config file that has key-value pairs that are ordered manually, and when you edit it, you want the key-value pairs to be ordered in the same way again. In that case, this wouldn't work reliably anyways, since Python dicts do not guarantee the order of keys, so it is only luck if the keys-value pairs get serialized in the same order as before. Or do I misunderstand your use-case? |
Hi, wow you're fast at replying :-) |
Oh good to know! Back when I learned python, it didn’t guarantee the order so I assumed that would still be the case. Can you do a PR, it would only require a new config variable "sort_keys", and passing that variable to the json and orjson dump functions. I would do it myself, but I am a bit short on time since I need to finish my masters thesis right now:) |
Also, an update to the docs would be required, but that’s also only a few lines of text |
First, love your lib, saw it on reddit and have replaced yours with my json config saver.
However, for me, the order of the keys is important and in function serialize_data_to_json_bytes in io_unsafe.py you always sort the keys. This hurts.
My personal opinion is not to do that there ? If you want to sort your keys then that could/should be done prior.
Kinda separate the purpose of serialize the data and ordering the data.
Alternatively you could add an option when creating the instance if you want an alternative solution.
Just my two cents.
for now I patch it with
The text was updated successfully, but these errors were encountered: