json-rust
json-rust copied to clipboard
Consistent roundtrips for whole number floats
When whole numbers other than 0 with decimal places are parsed and then converted back to string they maintain their decimal point unless than number is 0 in which case it gets stripped. it would be useful if 0 also retained its decimal place when being converted back to a string.
#[test]
fn test_consistent_output_types() {
let input = r#"{"one":1.0,"zero":0.0,"one_int":1,"zero_int":0}"#;
let parsed = json::parse(input).unwrap();
let output = parsed.to_string();
assert_eq!(input, output);
}
assertion `left == right` failed
left: "{\"one\":1.0,\"zero\":0.0,\"one_int\":1,\"zero_int\":0}"
right: "{\"one\":1.0,\"zero\":0,\"one_int\":1,\"zero_int\":0}"