We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
#[derive(Debug, serde::Deserialize)] #[serde(tag = "type", content = "data")] pub enum Data { #[serde(alias = "a")] A(Info), } #[derive(Debug, serde::Deserialize)] struct Info { timestamp: f64, } fn main() { let data = r#"{"type": "a", "data": {"timestamp": 1.10}}"#; let value: serde_json::Value = serde_json::from_str(data).unwrap(); println!("{:?}", value); let data: Data = serde_json::from_value(value).unwrap(); println!("{:?}", data); }
serde: 1.0.218, features = ["std", "derive"] serde_json: 1.0.140, features = ["std", "arbitrary_precision"]
If arbitrary_precision is off, succeed to deserialize by removing trailing zeros:
arbitrary_precision
Object {"data": Object {"timestamp": Number(1.1)}, "type": String("a")} A(Info { timestamp: 1.1 })
But, if arbitrary_precision is on, fail to deserialize due to trailing zeros:
Object {"data": Object {"timestamp": Number(1.10)}, "type": String("a")} thread 'main' panicked at src/main.rs:19:52: called `Result::unwrap()` on an `Err` value: Error("invalid type: map, expected f64", line: 0, column: 0)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
serde: 1.0.218, features = ["std", "derive"]
serde_json: 1.0.140, features = ["std", "arbitrary_precision"]
If
arbitrary_precision
is off, succeed to deserialize by removing trailing zeros:But, if
arbitrary_precision
is on, fail to deserialize due to trailing zeros:The text was updated successfully, but these errors were encountered: