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
Use lowercase strings for bool dict keys #614
Conversation
Fixes ultrajson#613 Also, * Consolidate key conversion for sorted and unsorted cases. * Fix memory leak of the "null" string when handling None dict key.
One thing I noticed is that objects of unknown types are usually passed through |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #614 +/- ##
==========================================
+ Coverage 91.67% 91.68% +0.01%
==========================================
Files 6 6
Lines 1946 1949 +3
==========================================
+ Hits 1784 1787 +3
Misses 162 162 ☔ View full report in Codecov by Sentry. |
e80d821
to
834c33e
Compare
@hugovk Reckon this constitutes a breaking change? It's not that unreasonable for someone to be using To be honest, I'm not particularly comfortable with interchanging one undefined behaviour for another. |
If we go for this, I would err on calling it a breaking change: the major bump will draw attention to the change, for those who don't care it doesn't matter, but for those who do, they were warned. |
@bwoodsend Do you mean that someone would iterate over all dict keys and call >>> json.dumps({True: 1, False: 2, None: 3})
'{"true": 1, "false": 2, "null": 3}'
>>> simplejson.dumps({True: 1, False: 2, None: 3})
'{"true": 1, "false": 2, "null": 3}'
>>> orjson.dumps({True: 1, False: 2, None: 3}, option=orjson.OPT_NON_STR_KEYS)
b'{"true":1,"false":2,"null":3}' It also seems odd to special case |
It would work for booleans, integers and floats. If that's all your data's keys contain then I don't see any reason why people wouldn't do it. I'm not saying it's a good idea but people do do weird stuff with this library. We don't have to change much before we get feature requests demanding that we add an option to enable some previous behaviour. I do agree that |
If we are discussing a real use case, then it seems highly unlikely that someone would have keys of mixed types of specifically just numbers and bools and nothing else. If they have other types in the mix, Of course, every change can break something12, but that's not a reason to not fix issues :) Footnotes |
Fixes #613
Also,