-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Python JSON module doesn't actually produce JSON #70293
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
Comments
The Python library JSON library doesn't emit JSON by default. Basically, JSON *does not allow
The default for emitting JSON should actually emit JSON. |
This is documented at https://docs.python.org/3/library/json.html#standard-compliance-and-interoperability and https://docs.python.org/3/library/json.html#infinite-and-nan-number-values |
The problem here is that JSON is *everywhere*, and I only ran into this particular issue after a whole bunch of digging as to why my "JSON" messages were disappearing in some javascript. Basically, with the default the way it is, you have interoperability bombs in every project that uses it to interface with other languages. In my case, I'm using Flask-SocketIO ( https://github.com/miguelgrinberg/Flask-SocketIO ), which uses JSON as it's transport, and it works fine until you have a NaN or infinity in your data, at which point the socket.io in the browser starts *silently* eating messages. Basically, if I call json.dumps, the principle of least astonishment dictated that you actually get, you know, JSON. If you have a module called something like |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: