Skip to content
New issue

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

allow deserialization to work with missing attributes #60

Closed
nicolai86 opened this issue Apr 17, 2015 · 4 comments
Closed

allow deserialization to work with missing attributes #60

nicolai86 opened this issue Apr 17, 2015 · 4 comments
Milestone

Comments

@nicolai86
Copy link

When parsing JSON I'd like to only parse parts of the payload, e.g.

given JSON like { 'x': 32, 'y': 12 } I'd expect serde to deserialize it using the following struct:

#[derive(Serialize, Deserialize)]
#[allow(non_snake_case)]
struct Point {
    y: f32,
}

However, this fails with an UnknownField("x") error.

This is important if you are only interested in parts of the payload, or if working with dynamic payload.

@nicolai86 nicolai86 mentioned this issue Apr 17, 2015
Closed
19 tasks
@jgallagher
Copy link

I think this is a dupe of #44, although that issue mentions adding an annotation to allow skipping unknown fields. I think this issue's request should be the default; that's how most JSON parsers in other languages (and rustc-serialize) work.

@softprops
Copy link
Contributor

+1

1 similar comment
@dovahcrow
Copy link

+1

@erickt
Copy link
Member

erickt commented Jan 18, 2016

This was implemented in #204, and will be a part of serde 0.7.0 when it comes out, hopefully within the week!

@erickt erickt closed this as completed Jan 18, 2016
@dtolnay dtolnay added this to the v0.7.0 milestone May 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants