bompandreean opened a new issue, #219:
URL: https://github.com/apache/avro-rs/issues/219
Starting from version 0.18.0 of the apache-avro crate, serde JSON
deserialization behaves unexpectedly even if the avro crate is not directly
used. The mere presence of the avro crate as a dependency causes a failure in
deserialization logic.
Steps to reproduce:
1. Create a new project with any version of serde.
2. Add the following test code (which should pass as expected):
#[test]
fn test(){
#[derive(Deserialize, PartialEq, Debug)]
struct S3{
f1: Option<f64>,
#[serde(flatten)]
inner: Inner,
}
#[derive(Deserialize, PartialEq, Debug)]
struct Inner{
f2: f64,
}
let test = "{
\"f1\": 0.3,
\"f2\": 3.76
}";
let result= serde_json::from_str::<S3>(&test);
println!("result : {:#?}", result);
result.unwrap();
}
3. Now add any version of apache-avro greater than 0.17.0 to Cargo.toml,
e.g.:
apache-avro = "0.18.0"
4. Re-run the test. The test will now fail with the following error:
Error: invalid type: map, expected f64 at line 5 column 3
Notes:
The error does not occur when apache-avro = "0.17.0" is used.
The issue only appears when using floating point numbers like 0.3 and 3.76.
If the values are whole numbers (e.g., 1, 2), the deserialization works fine.
The avro crate is not used in the deserialization code – its presence as a
dependency appears to alter serde behavior globally, which may indicate a side
effect or conflicting serde deserializer implementation introduced in avro >=
0.18.0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]