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

Fails to decode struct if field is missing #21

Open
fogfish opened this issue Apr 4, 2020 · 1 comment
Open

Fails to decode struct if field is missing #21

fogfish opened this issue Apr 4, 2020 · 1 comment

Comments

@fogfish
Copy link

fogfish commented Apr 4, 2020

The library fails to decode a struct if field is missing.

E.g. I do have a struct

type TokenExchange struct {
  Type string `form:"grant_type"`
  Code string `form:"code"`
}

The input string to parse

grant_type=authorization_code&code=xxx&client_id=xxx

The library fails to decode string with an error

client_id doesn't exist in main.TokenExchange

I would expect that library skips client_id.

@fizzy123
Copy link

If you can set ignoreUnknownKeys to true and you won't have this problem anymore.

form/decode.go

Line 59 in 523a5da

func (d *Decoder) IgnoreUnknownKeys(ignoreUnknown bool) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants