I've been dealing with a lot of structs to parse and convert XML to JSON 
and viceversa. My main problem with this method is that some of the 
structures have nested structures like this, for example:

type tantu struct {
ConfidentialAccess struct {
ConfidentialAccessMode  string `xml:"confidentialAccessMode,"`
ConfidentialAccessLevel string `xml:"confidentialAccessLevel,"`
} `xml:"confidentialAccess,omitempty"`
}

<tantu>
        <confidentialAccess>
                <confidentialAccessMode></confidentialAccessMode>
                <confidentialAccessLevel></confidentialAccessLevel>
        </confidentialAccess>
</tantu>

In some cases I need that the nested structure doesn't convert to XML 
because it causes errors on the API that I'm working on. I know that this 
is a issue with Go and the XML package. So I was trying to change the tags 
using reflection, but I cannot change the value of the StructTag.

func ChangeTags(t interface{}) {
        x := "xml:"\-"\"
val := reflect.ValueOf(t).Elem()
c := reflect.New(val.Type()).Elem()
for i := 0; i < val.NumField(); i++ {
ov := val.Field(i)
vK := val.Field(i).Kind()
val.Type().Field(i).Tag = x
}

Is it possible to change the value, or is it a constraint of Go itself? Are 
there any workarounds for this?

Thanks in advance!


-- 
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.

Reply via email to