Skip to content
New issue

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

Deserialize to concrete type with error line/column #33

Open
probablykasper opened this issue May 30, 2023 · 1 comment
Open

Deserialize to concrete type with error line/column #33

probablykasper opened this issue May 30, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@probablykasper
Copy link

probablykasper commented May 30, 2023

I'd really like a way to deserialize into a struct while seeing the line/column of errors when there's an invalid type.

With serde_json::from_str I parse a string directly into a struct:

let settings_str = fs::read_to_string(&file_path).unwrap();
serde_json::from_str(&settings_str).unwrap()

And that shows the line/column. But with parse_to_serde_value() & serde_json::from_value, you lose that:

thread 'main' panicked at 'called Result::unwrap() on an Err value: Error("invalid type: boolean true, expected struct Example", line: 0, column: 0)', src/settings.rs:32:40

@tv42

This comment was marked as outdated.

@dsherret dsherret changed the title Deserialize with error line/column Deserialize to concrete type with error line/column Oct 19, 2024
@dsherret dsherret added the enhancement New feature or request label Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants