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

gopherbot opened this issue Jan 8, 2013 · 5 comments

encoding/json: panic on mismatched input #4628

gopherbot opened this issue Jan 8, 2013 · 5 comments


Copy link


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

The following code panics, it should return an error.

package main
import (

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))
Copy link

dsymonds 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.

Copy link

kisielk commented Jan 12, 2013

Comment 2:

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

Copy link

Comment 3:

Indeed, sorry for that.

Copy link

Comment 4:

Status changed to Started.

Copy link

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.
None yet

No branches or pull requests

5 participants