Skip to content

Can't parse float when serde_json "arbitrary_precision" feature is enabled #48

Description

@ppom0

Hi, and many thanks for this crate. On NDJSON, I could achieve x2 speed on my whole program, comparing to plain serde_json!

However, I need on another part of my project the 'arbitrary_precision' feature of serde_json.

This features seems incompatible with serde_json_borrow, as this code works only when serde_json "arbitrary_precision" feature is disabled:

fn main() {
    let original_json = r#"{"f":1.2}"#;
    // This always works
    println!(
        "serde_json: {:?}",
        serde_json::from_str::<serde_json::Value>(&original_json)
    );
    // This works only if feature is disabled
    println!(
        "serde_json_borrow: {:?}",
        serde_json::from_str::<serde_json_borrow::Value>(&original_json)
    );
}

The error printed is:

Error("invalid type: string \"$serde_json::private::Number\", expected tuple struct CowStr", line: 1, column: 8)

This feature is only documented here, to my knowledge: https://docs.rs/serde_json/latest/serde_json/struct.Number.html#method.from_i128

Do you think it would be feasible to support this feature?

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