I expected below code to print an object of type struct J
, however it prints a map object of type map[string]interface{}
. I can feel why it acts like that, however when I run, reflect.ValueOf(i).Kind(), it returns Struct
, so it kinda gives me the impression that Unmarshal
method should return type J
instead of a map. Could anyone enlighten me ?
type J struct {
Text string
}
func main() {
j := J{}
var i interface{} = j
js := "{\"Text\": \"lala\"}"
json.Unmarshal([]byte(js), &i)
fmt.Printf("%#v", i)
}