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

to_value(NAN) should be null #155

Closed
dtolnay opened this issue Sep 24, 2016 · 1 comment
Closed

to_value(NAN) should be null #155

dtolnay opened this issue Sep 24, 2016 · 1 comment
Labels

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 24, 2016

extern crate serde_json;

fn main() {
    let value = serde_json::to_value(::std::f64::NAN);
    println!("value: {}", value);
    println!("value.is_null(): {}", value.is_null());
}

Expected:

value: null
value.is_null(): true

Actual:

value: null
value.is_null(): false
@dtolnay dtolnay added the bug label Sep 24, 2016
@traviskaufman
Copy link
Contributor

I can look into this.

Looks like serializing Value::F64(_) simply proxies to serialize_f64(v), where it should really check for FpCategory::{Nan, Infinite}, as serialization only works for finite values (https://tc39.github.io/ecma262/#sec-serializejsonproperty).

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

No branches or pull requests

2 participants