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: Wrong type in a field breaks decoding of following fields #19526

Closed
Hunsin opened this issue Mar 13, 2017 · 2 comments
Closed

Comments

@Hunsin
Copy link

Hunsin commented Mar 13, 2017

What version of Go are you using (go version)?

1.7.3 and 1.8

What operating system and processor architecture are you using (go env)?

amd64 linux

What did you do?

Go Playground link

What did you expect to see?

Type of Age in go struct is string, it will return {Name: "John", Age: "", Gen: "M"} and error message.
Output:
json: cannot unmarshal number into Go struct field person.age of type string
JohnM

What did you see instead?

In raw json, "gen" field shows after "age", it seems wasn't touched by decoder.
Output:
json: cannot unmarshal number into Go struct field person.age of type string
John

@bradfitz
Copy link
Contributor

I suppose we could document this, but it's been like this forever so I don't see a good reason to change it.

@bradfitz bradfitz added this to the Go1.9 milestone Mar 13, 2017
@gopherbot
Copy link

CL https://golang.org/cl/44711 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants