Skip to content

Add support for 'nan' #921

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

Closed
wants to merge 5 commits into from

Conversation

patrickelectric
Copy link

@patrickelectric patrickelectric commented Aug 24, 2022

This PR allows the usage of 'nan' in json, like json!(nan).
With that.. null could be used as +/-infinity, and that can help people that uses serde serialization for more complex data types and protocol standards.

To explain a bit better my use case, I'm using serde with json to create a REST API based the mavlink protocol standard, but some messages uses nan to define some specific behavior for some sensors.

PS: since this needs std::f64::NAN to use it, should I move it as a feature ?

Helps #202

Signed-off-by: Patrick José Pereira <[email protected]>
Signed-off-by: Patrick José Pereira <[email protected]>
@patrickelectric patrickelectric force-pushed the add_nan2 branch 7 times, most recently from 03e4a39 to 9de719a Compare August 24, 2022 20:27
Signed-off-by: Patrick José Pereira <[email protected]>
Signed-off-by: Patrick José Pereira <[email protected]>
Signed-off-by: Patrick José Pereira <[email protected]>
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nan is not a valid JSON value, so I don't think it would be appropriate for a JSON parser to accept in the input or produce it. I would prefer not to make this change.

@dtolnay dtolnay closed this Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants