Assume following JSON:
{
"person": {
"first_name": "Ala",
"last_name": "Makota"
}
}
Is it possible to deserialize this object to a struct like following, skipping "person"
?
#[derive(Deserialize)]
struct Person {
first_name: String,
last_name: String,
}
It's easy to deserialize the JSON object to a wrapped struct, like this:
#[derive(Deserialize)]
struct Object {
person: Person
}
but in my case, I'm only interested in Person
structure.
EDIT:
While I'm aware that I could use serde_json
's Value
type to operate on JSON almost as on a Map
, I'm specifically interested in the possibility of leveraging derive
and maybe attributes to achieve my goal.