Skip to content

Instantly share code, notes, and snippets.

@piedoom
Last active June 26, 2017 23:34
Show Gist options
  • Save piedoom/5b52920120fd6a1b8dfdea62154ee5d6 to your computer and use it in GitHub Desktop.
Save piedoom/5b52920120fd6a1b8dfdea62154ee5d6 to your computer and use it in GitHub Desktop.
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"user": { // <== only care about this object
"name": "name",
"likes": 46310,
...
// Let's pretend the User object looks like this:
pub struct User {
name: String,
likes: u32
}
// Of course, when deseralized with the JSON above, we receive an error since the fields we want to access are not in the root object.
// is there an easier way of skipping to the "user" object besides deseralizing the whole structure?
// e.g. I want to avoid this:
pub struct response {
user: User
}
pub struct User {
// etc...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment