Hello, My guess: If you dont pass in a pointer, then you pass a value. What would be the point of updating the value that you will never see and that will get discarded? Hence it returns a map that provides the unmarshaled values so at least you have something to work with.
Le mardi 2 mai 2017 20:59:52 UTC+2, Brian Stengaard a écrit : > > Hey Gophers, > > When unmarshalling JSON into a struct with a blank interface (interface{}) > I get a surprising result: > > If I set the field to a pointer to a T value before unmarshalling, the > data is filled out on the T value as expected. (See I2 in the playground > example.) > > If I set the field to a T value before unmarshalling, field will be set to > a map[string]interface{} when returning, I was expecting a T value. > > Since the field is not nil I would expect json.Unmarshal to just fill in > the fields on the data structure provided, not override the field value. > > What am I missing? > > Example: https://play.golang.org/p/O-55nj0h44 why is I1 a > map[string]interface{} when I already gave it a T value? > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.