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: panic on mismatched input #4628

Closed
gopherbot opened this issue Jan 8, 2013 · 5 comments

Comments

Projects
None yet
5 participants
@gopherbot
Copy link

commented Jan 8, 2013

by borman@google.com:

Go version: import 8906cf341c9b (2012-01-07)

The following code panics, it should return an error.

package main
import (
    "fmt"
    "encoding/json"
)

type errorMessage struct {
        Message string `json:"message"`
        Success bool   `json:"success"`
        Error   string `json:"data"`
}

var input = `{
  "data": {
    "user": "name"
  }, 
  "message": "Success", 
  "success": true
}`

func main() {
    data := []byte(input)
    em := errorMessage{}
    fmt.Println(json.Unmarshal(data, &em))
}
@dsymonds

This comment has been minimized.

Copy link
Member

commented Jan 8, 2013

Comment 1:

This is a relatively recent regression.

Labels changed: added priority-soon, packagebug, removed priority-triage.

Status changed to Accepted.

@kisielk

This comment has been minimized.

Copy link
Contributor

commented Jan 12, 2013

Comment 2:

I used hg bisect to determine the regression occurred in 5083a8d8cc89
@remyoudompheng

This comment has been minimized.

Copy link
Contributor

commented Jan 12, 2013

Comment 3:

Indeed, sorry for that.
https://golang.org/cl/7100049/
@remyoudompheng

This comment has been minimized.

Copy link
Contributor

commented Jan 13, 2013

Comment 4:

Status changed to Started.

@remyoudompheng

This comment has been minimized.

Copy link
Contributor

commented Jan 14, 2013

Comment 5:

This issue was closed by revision 406ca3c.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015

@rsc rsc removed the go1.1 label Apr 14, 2015

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

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.