type XMLStruct struct {
Name string `json:"name" json:"FirstName"`
Date string `xml:"Date" xml:"pudDate"`
}
type XMLStruct struct {
Name string `json:"name" json:"FirstName"`
Date string `xml:"Date" xml:"pudDate"`
}
收起
I am going to say no not in this way.
you can do this,
type XMLStruct struct {
Name string `json:"name" xml:"name"`
Date string `json:"Date" xml:"Date"`
}
or this,
type XMLStruct struct {
Name string `json:"name, omitempty" xml:"name, omitempty"`
Date string `json:"Date, omitempty" xml:"Date, omitempty"`
FirstName string `json:"FirstName, omitempty" xml:"FirstName, omitempty"`
}
But I don't believe that you can map multiple json names to one struct field and I think that the reason for this would be is what if they both existed in the json structure, which one do you retain and throw away etc.
报告相同问题?