Navigation Menu

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
Closed

encoding/json: panic on mismatched input #4628

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

Comments

@gopherbot
Copy link

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

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.

@kisielk
Copy link
Contributor

kisielk commented Jan 12, 2013

Comment 2:

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

@remyoudompheng
Copy link
Contributor

Comment 3:

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

@remyoudompheng
Copy link
Contributor

Comment 4:

Status changed to Started.

@remyoudompheng
Copy link
Contributor

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

No branches or pull requests

5 participants