Open nkovacs opened 3 years ago
+1 to this. Also, the returned error points to the end of file. Here 220 is the last }
:
Error: invalid type: null, expected a string at line 220 column 1
It seems it's not the issue of path-to-error
itself, as pure deserialisation returns the same result.
@jonasbb This is a duplicate of https://github.com/serde-rs/serde/issues/1183. With flatten the data gets deserialized into an intermediate buffer, advancing the location in the yaml file, but then fails to deserialize the buffer data into the struct.
@dtolnay
This is really true I create an example using a struct that has flatten
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default)]
pub struct TestStruct {
#[serde(flatten)]
test: Test<Bus>,
id: Option<String>,
}
And when I use
let result: Result<TestStruct, _> = serde_path_to_error::deserialize(
&mut serde_json::Deserializer::from_str(line.as_str()),
);
match result {
Ok(response) => {
print!("{:?}", response);
}
Err(err) => {
panic!(
"Deserialization error at path: {}\nError: {}",
err.path(),
err
);
}
}
The path is "."