Closed jakerobers closed 6 years ago
Never mind, I think I have it figured out. Posting solution for others:
let document = response.json::<JsonApiDocument>();
match document.data {
Some(PrimaryData::Multiple(vacations)) => {
for resource in vacations.iter() {
let vacation: Vacation = Vacation::from_jsonapi_resource(resource, &document.included).unwrap();
print!("vacation {}", vacation.start_date);
}
},
_ => print!("there was an error")
}
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'm a beginner with rust, and apologize if this question is really basic:
What does the usage look like for converting a JsonApiDocument with an array of results to a vector of jsonapi_model structs.
It looks like I need to handle this case https://github.com/michiel/jsonapi-rust/blob/master/src/model.rs#L38 but when it hits https://github.com/michiel/jsonapi-rust/blob/master/src/model.rs#L182, the return type is the singular jsonapi_model and not a vector of them (I think).
thanks in advance