I'm trying to unmarshal some XML into a structure with an interface{} type. However whenever I try to run it, the code doesn't pick up anything at all. All of the other elements appear to work fine, and if I set the type to string or []byte it will work, however I need it to be more flexible than that.
The element I am interested in is on line 32 - FloorRefID
https://play.golang.org/p/Ehr8qx1aWf
<?xml version="1.0" encoding="UTF-8"?>
<Locations totalPages="1" currentPage="1" pageSize="25">
<WirelessClientLocation macAddress="00:00:00:00:00:00">
<MapInfo mapHierarchyString="Head office>Ground floor>Store" floorRefId="-1122334455667789">
<Image imageName="floorPlan1.png" />
</MapInfo>
<MapCoordinate x="2850" y="3000" unit="FEET" />
</WirelessClientLocation>
<WirelessClientLocation macAddress="11:11:11:11:11:11">
<MapInfo mapHierarchyString="Head office>Ground floor>Store" floorRefId="-1122334455667789">
<Image imageName="floorPlan1.png" />
</MapInfo>
<MapCoordinate x="10.72" y="76.49" unit="FEET" />
</WirelessClientLocation>
<WirelessClientLocation macAddress="26:cd:96:46:0b:2b">
<MapInfo floorRefId="0" />
<MapCoordinate x="51.52" y="4.2" unit="FEET" />
</WirelessClientLocation>
</Locations>
To give some context; I am working on a project integrating with a vendor in which sometimes we receive the data as XML and sometimes as JSON. I wanted to build something that could unmarshal the structure for both, rather than duplicating the structure set. It has many substructures which means that its a lot more work to keep 2 structures which are almost identical except for this one attribute.
When we receive the JSON data, the field can be given as a string or a number.
I have read that you cannot unmarshal into an interface, but does anyone know of a way around this issue for my scenario?