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

Deserialization failure with struct flattening and Query #623

Closed
vmalloc opened this issue Dec 11, 2018 · 3 comments
Closed

Deserialization failure with struct flattening and Query #623

vmalloc opened this issue Dec 11, 2018 · 3 comments
Labels
C-bug-upstream Category: bug in a dependency (including actix-net)

Comments

@vmalloc
Copy link
Contributor

vmalloc commented Dec 11, 2018

Trying to use the following with the Query extractor:

#[derive(Debug, Deserialize)]
pub struct Info {
    pub(crate) endpoint: Option<String>,
    #[serde(flatten)]
    pub(crate) timing: Timing,
}

#[derive(Debug, Deserialize)]
pub struct Timing {
    pub(crate) total: f64,
    pub(crate) active: f64,
}

Trying this with a URL containing numbers (e.g. /route?total=1.1&active=2.2&endpoint=bla) returns an error "invalid type: string "1.1" expected f64).

Without flattening it seems to work correctly though...

@DoumanAsh
Copy link
Contributor

You can try to use serde_urlencoded directly to parse your string, I suspect it is a problem there

@DoumanAsh DoumanAsh added the C-bug-upstream Category: bug in a dependency (including actix-net) label Dec 11, 2018
@vmalloc
Copy link
Contributor Author

vmalloc commented Dec 11, 2018

@DoumanAsh will try. Thanks!

@vmalloc
Copy link
Contributor Author

vmalloc commented Dec 11, 2018

Seems to already be a known issue: nox/serde_urlencoded#33

@vmalloc vmalloc closed this as completed Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug-upstream Category: bug in a dependency (including actix-net)
Projects
None yet
Development

No branches or pull requests

2 participants