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

Comments

Projects
None yet
3 participants
@Hunsin
Copy link

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

This comment has been minimized.

Copy link
Member

commented Mar 13, 2017

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

This comment has been minimized.

Copy link

commented Jun 3, 2017

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

@gopherbot gopherbot closed this in 3cc2da6 Jun 5, 2017

@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.
You can’t perform that action at this time.