Your value will be marshalled into a float64
. Plus you are not accessing a.data
but a
instead which is a struct which is causing the error.
fmt.Printf("%#v\n", a) // &main.JSON{data:1}
fmt.Println(reflect.TypeOf(a.data)) // float64
x := int(a.data.(float64))