Skip to content
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/xml: not properly unmarshaling through interface{} #6836

Closed
gopherbot opened this Issue Nov 26, 2013 · 6 comments

Comments

Projects
None yet
4 participants
@gopherbot
Copy link

gopherbot commented Nov 26, 2013

by mike@mccartney.net:

I am seeing an inconsistency between the way encoding/xml and encoding/json handle
unmarshaling into structs containing interface{} fields.  Specifically, if the
interface{} field is non-nil and pointing to a struct with an appropriate schema, the
xml will not unmarshal into the pointed-to struct but the json unmarshaler will.  I want
the xml unmarshaler to behave like the json unmarshaler.

I'm using go version devel +f4d1cb8d9a91 Thu Sep 19 22:34:33 2013 +1000 darwin/amd64

The following code demonstrates the different behavior:
http://play.golang.org/p/-i96HoWP_A

Notice that the jsonResult contains an Address with City and State filled out but the
xmlResult does not.

I believe the code that is doing the right thing in json is here:
http://code.google.com/p/go/source/browse/src/pkg/encoding/json/decode.go#307

I don't know how best to fix the xml code, but i think the fix needs to go here:
http://code.google.com/p/go/source/browse/src/pkg/encoding/xml/read.go#287
@josharian

This comment has been minimized.

Copy link
Contributor

josharian commented Nov 26, 2013

Comment 1:

Test and possible fix at https://golang.org/cl/33140043
@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@dsymonds

This comment has been minimized.

Copy link
Member

dsymonds commented Dec 2, 2013

Comment 3:

Labels changed: added priority-soon, packagebug, removed priority-triage.

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added release-none, removed go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@josharian

This comment has been minimized.

Copy link
Contributor

josharian commented Apr 8, 2014

Comment 6:

This issue was closed by revision e79bab3.

Status changed to Fixed.

@gopherbot gopherbot added fixed labels Apr 8, 2014

@golang golang locked and limited conversation to collaborators Jun 25, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.