go version 1.2 linux/amd64
What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.
http://play.golang.org/p/d5qCvqjhhe
What happened?
Basically some slices are treated as of type interface{} when used with json.Unmarshal,
even when they should have enough type information to be treated as of being of some
specific type.
This deals with a true corner case I believe few would be interested in, and it might
even be some design decision made to simplify the implementation of
json.Unmarshal/json.Decode/etc. A good defense of the behavior observed would be
regarded as resolving the issue.
Thank you for making Go great!
The text was updated successfully, but these errors were encountered:
In the cases whose behaviour you want to be different, you are passing in a pointer to
an interface{}. The encoding/json docs describe how JSON is unmarshaled into an
interface value, and that is what you are seeing. So this is behaving correctly
according to the package docs.
I agree that this makes it hard to decode into a slice created by reflect.MakeSlice. I
think you'll have to walk the map and assign to the slice using the reflect methods. At
least, I don't immediately see another way to do it.
Alright. Thank you for your time.
By the way, I would like to see some decoder/encoder for transforming to and from struct
<-> map[string]interface{} in the standard lib. That would have helped me out.
by emanuelpalm:
The text was updated successfully, but these errors were encountered: