Skip to content

Consistent roundtrips for whole number floats #218

@saty9

Description

@saty9

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}" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions