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

encoding/json: use different error type for unknown field if they are disallowed #40982

Open
Segflow opened this issue Aug 22, 2020 · 1 comment · May be fixed by #40983
Open

encoding/json: use different error type for unknown field if they are disallowed #40982

Segflow opened this issue Aug 22, 2020 · 1 comment · May be fixed by #40983

Comments

@Segflow
Copy link
Contributor

@Segflow Segflow commented Aug 22, 2020

On Go 1.15 and below, json decoder returns a generic error when unknown fields are disallowed (via Decoder.DisallowUnknownFields. See https://github.com/golang/go/blob/master/src/encoding/json/decode.go#L737-L739

It may be useful to return a different error type so the caller can detect when it is the case.

The only way to detect that currently is to interpret the string returned by Error

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

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.