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
Project for easy repro here.
Code:
const JSON_TEXT: &str = r#" { "things_tag": "animals", "items": [ {"animal_tag": "cat"}, {"animal_tag": "xenomorph"}, {"animal_tag": "dog"} ] } "#; fn main() { let stuff = serde_json::from_str::<Things>(JSON_TEXT); println!("{:?}", stuff); } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[serde(tag = "things_tag", rename_all = "snake_case")] enum Things { Animals(Animals), Plants(Plants), } #[derive(Debug, serde::Serialize, serde::Deserialize)] struct Animals { items: Vec<Animal>, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[serde(tag = "animal_tag", rename_all = "snake_case")] enum Animal { Cat, Dog, } #[derive(Debug, serde::Serialize, serde::Deserialize)] struct Plants {}
Expected output:
Err(Error("unknown variant `xenomorph`, expected `cat` or `dog`", line: 6, column: 34))
Observed output:
Err(Error("unknown variant `xenomorph`, expected `cat` or `dog`", line: 0, column: 0))
Note how the line: 0, column: 0 information is incorrect.
line: 0, column: 0
The problem disappears when the tag = "things_tag" setting is removed (branch), but persists when only the tag = "animal_tag" is removed (branch).
tag = "things_tag"
tag = "animal_tag"
The text was updated successfully, but these errors were encountered:
Seems related to serde-rs/serde#1621
Sorry, something went wrong.
No branches or pull requests
Project for easy repro here.
Code:
Expected output:
Observed output:
Note how the
line: 0, column: 0
information is incorrect.The problem disappears when the
tag = "things_tag"
setting is removed (branch), but persists when only thetag = "animal_tag"
is removed (branch).The text was updated successfully, but these errors were encountered: