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
#[macro_use] extern crate serde_derive; extern crate serde; extern crate csv; #[derive(Debug, Deserialize)] struct Record { city: String, region: String, country: String, #[serde(flatten)] dem: Demographics, } #[derive(Debug, Deserialize)] struct Demographics { population: u64, } const INPUT: &[u8] = b"\ city,region,country,population Southborough,MA,United States,9686 Northbridge,MA,United States,14061 Westborough,MA,United States,29313 Marlborough,MA,United States,38334 Springfield,MA,United States,152227 Springfield,MO,United States,150443 Springfield,NJ,United States,14976 Springfield,OH,United States,64325 Springfield,OR,United States,56032 Concord,NH,United States,42605"; fn main() { let mut input = INPUT; let mut rdr = csv::Reader::from_reader(&mut input); for record in rdr.deserialize::<Record>() { println!("{:?}", record.unwrap()); } }
CSV deserialize error: record 1 (line: 2, byte: 31): missing field `population`
The text was updated successfully, but these errors were encountered:
Fixed in ea0012f.
Record { city: "Southborough", region: "MA", country: "United States", dem: Demographics { population: 9686 } } Record { city: "Northbridge", region: "MA", country: "United States", dem: Demographics { population: 14061 } } Record { city: "Westborough", region: "MA", country: "United States", dem: Demographics { population: 29313 } } Record { city: "Marlborough", region: "MA", country: "United States", dem: Demographics { population: 38334 } } Record { city: "Springfield", region: "MA", country: "United States", dem: Demographics { population: 152227 } } Record { city: "Springfield", region: "MO", country: "United States", dem: Demographics { population: 150443 } } Record { city: "Springfield", region: "NJ", country: "United States", dem: Demographics { population: 14976 } } Record { city: "Springfield", region: "OH", country: "United States", dem: Demographics { population: 64325 } } Record { city: "Springfield", region: "OR", country: "United States", dem: Demographics { population: 56032 } } Record { city: "Concord", region: "NH", country: "United States", dem: Demographics { population: 42605 } }
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: