-
Notifications
You must be signed in to change notification settings - Fork 364
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
Add an allow_nan keyword argument to dumps, defaults to True #327
Conversation
with this ujson matches the builtin json behavior for NaN and Inf. if a user wants to retain the old behavior they can pass allow_nan=False to ensure strict json compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I think matching the stdlib json
library is a good idea.
This is failing on Python 2.7, so let's merge it once 2.7 is dropped (#383).
I wonder, should this be considered a breaking change? It's okay if it is, as it'll be a major bump anyway when dropping 2.7.
And if so, do you think there should be a deprecation warning beforehand?
Is there a timeline on dropping 2.7 support? Would love to have this merged in and released. |
There's been no objections to #383, and 2.7 is now EOL and the final 2.7 has been released, so I think we're good to drop 2.7 pretty much now. #399 is the only thing in master as yet unreleased, I've left a comment there asking if it's needed in a final release supporting 2.7 first. If so, I'll do that first and we can then drop 2.7 shortly thereafter. |
Thank you! |
It seems weird that support for This means you can dumps things that you can't loads: MWE: import ujson
data = [float('nan')]
text = ujson.dumps(data)
print('data = {!r}'.format(data))
print('text = {!r}'.format(text))
try:
recon = ujson.loads(text)
except Exception as ex:
print('ex = {!r}'.format(ex))
else:
print('recon = {!r}'.format(recon)) |
with this ujson matches the builtin json behavior for NaN and Inf.
if a user wants to retain the old behavior they can pass allow_nan=False
to ensure strict json compatibility.
This should resolve #311