Skip to content

Bug: Panic on json.Unmarshal #717

Open
@hajimehoshi

Description

@hajimehoshi

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions