-
Notifications
You must be signed in to change notification settings - Fork 640
u128 doesn't work for Value #502
Copy link
Copy link
Closed
Labels
Description
Looks like there's a bug in serde_json. This program:
#[macro_use]
extern crate serde_json;
use std::str::FromStr;
fn main() {
let string = format!("{}", u128::max_value());
println!("{}", string);
let val = serde_json::value::Value::from_str(&string);
let val2 = serde_json::to_value(u128::max_value());
println!("{:#?}, {:#?}", val, val2);
}
outputs:
340282366920938463463374607431768211455
Ok(
Number(
340282366920938500000000000000000000000.0
)
), Err(
Error("u128 is not supported", line: 0, column: 0)
)
if you put arbitrary_precision feature, then Value works 100% without cutting precision, if you do it via u128 => String => Value. However direct conversion u128 => Value with to_value results in error.
Reactions are currently unavailable