google / google/serde_json_lenient
Trailing commas within ignored fields are not ignored
- Dominant language
- Rust
- Stars
- 27
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
```rust
use serde::Deserialize;
fn main() {
#[derive(Deserialize)]
struct Test {
field1: i64,
}
let mut deserializer = serde_json_lenient::Deserializer::from_str(
r#"
{
"field1": 1,
"field2": [
1,
2,
3,
],
}
"#,
);
deserializer.set_ignore_trailing_commas(true);
let _test = Test::deserialize(&mut deserializer).unwrap();
// let _test = serde_json_lenient::Value::deserialize(&mut deserializer).unwrap();
}
```
It seems like when deserializing directly to a type implementing `serde::Deserialize`, if a field is completely ignored, then the JSON within that ignored field is not properly treated leniently?
In this example, calling `Test::deserialize` will fail with
```
called `Result::unwrap()` on an `Err` value: Error("expected value", line: 8, column: 17)
```
but calling `serde_json_lenient::Value::deserialize` will not.
Contributor guide
Assessment
This issue has not been assessed yet.