Skip to content

Bug: Panic on json.Unmarshal #717

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

Open
hajimehoshi opened this issue Nov 6, 2017 · 1 comment
Open

Bug: Panic on json.Unmarshal #717

hajimehoshi opened this issue Nov 6, 2017 · 1 comment
Labels

Comments

@hajimehoshi
Copy link
Member

json.Unmarshal causes panic when a map to a struct values that has UnmarshalText is given.

https://gopherjs.github.io/playground/#/QeyQssFhyq

package main

import (
	"encoding/json"
	"fmt"
)

type Object [3]byte

func (o Object) UnmarshalText(text []byte) error {
	return nil
}

func main() {
	const jsonStr = `{"foo": "foo"}`
	vals := map[string]Object{}
	if err := json.Unmarshal([]byte(jsonStr), &vals); err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", vals["foo"])
}

Expected result:

No panics.

Actual result

panic: ap.$get is not a function 
@hajimehoshi
Copy link
Member Author

It looks like this is duplicated with #662?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants