Skip to content
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

Address Infinity and NaN JSON Serialisation #7

Open
MarkKoz opened this issue Aug 3, 2019 · 1 comment
Open

Address Infinity and NaN JSON Serialisation #7

MarkKoz opened this issue Aug 3, 2019 · 1 comment

Comments

@MarkKoz
Copy link
Member

MarkKoz commented Aug 3, 2019

Quote from Python's json module documentation:

This module does not comply with the RFC in a strict fashion, implementing some extensions that are valid JavaScript but not valid JSON. In particular:

  • Infinite and NaN number values are accepted and output;

This is a problem because JavaScript's JSON parser will consider values such as Infinity (note this is not a string) as invalid.

A custom JSONEncoder can be used to address these issues, but the question remains to what these values should be serialised. What format will allow JavaScript to properly interpret them? Oddly enough, JS itself serialises Infinity to null so that's not an answer.

@64json
Copy link
Member

64json commented Aug 27, 2019

Sorry for the late response. I think tracers.py should (still) simply serialize Infinity and NaN to null so that it behaves the same as tracers.js does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants