New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encoding/json: unexpected json.Unmarshal behavior with maps #12972
Comments
749b391 added said documentation and a test for the behaviour. Unfortunately, the test itself is broken, too. https://github.com/golang/go/blob/master/src/encoding/json/decode_test.go#L313 is supposed to test the overwriting of the map. However, in https://github.com/golang/go/blob/master/src/encoding/json/decode_test.go#L536 the initial value gets thrown away and replaced with an empty map. That way, the test doesn't actually test the overwriting of the map. |
Furthermore, this doesn't look like a regression. It does still overwrite slices; and Go 1.4.2 didn't overwrite maps, either. |
http://play.golang.org/p/HTjkkCEQBV https://github.com/golang/go/blob/release-branch.go1.5/src/encoding/json/decode.go#L521 |
CL https://golang.org/cl/16020 mentions this issue. |
/cc @rsc |
It's entirely possible we should change the docs instead of changing the implementation. |
seems like not changing one of the implementations (slices or maps) leads to inconsistency in the api. if that matters at all in your decision. |
CL https://golang.org/cl/17230 mentions this issue. |
http://golang.org/src/encoding/json/decode.go?s=2621:2669#L64
But, while unmarshalling it behaves differently.
http://play.golang.org/p/HTjkkCEQBV
I'm totally in favor of this behavior but what docs is saying isn't correct.
That make sense?
The text was updated successfully, but these errors were encountered: