Source File
unmarshal.go
Belonging Package
github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
package xmlutil
import (
)
func ( interface{}, *xml.Decoder, string) error {
, := XMLToStruct(, nil)
if != nil {
return
}
if .Children != nil {
for , := range .Children {
for , := range {
if , := .Children[]; {
= [0] // pull out wrapped element
}
= parse(reflect.ValueOf(), , "")
if != nil {
if == io.EOF {
return nil
}
return
}
}
}
return nil
}
return nil
}
if , := .Interface().([]byte); ! {
= "list"
}
case reflect.Map:
= "map"
}
}
switch {
case "structure":
if , := .FieldByName("_"); {
= .Tag
}
return parseStruct(, , )
case "list":
return parseList(, , )
case "map":
return parseMap(, , )
default:
return parseScalar(, , )
}
}
if := .Get("payload"); != "" {
, := .FieldByName()
return (.FieldByName(), , .Tag)
}
for := 0; < .NumField(); ++ {
:= .Field()
if := .Name[0:1]; strings.ToLower() == {
continue // ignore unexported fields
}
func ( reflect.Value, *XMLNode, reflect.StructTag) error {
:= .Type()
if .Get("flattened") == "" { // look at all item entries
:= "member"
if := .Get("locationNameList"); != "" {
=
}
if , := .Children[]; {
if .IsNil() {
.Set(reflect.MakeSlice(, len(), len()))
}
for , := range {
:= parse(.Index(), , "")
if != nil {
return
}
}
}
} else { // flattened list means this is a single element
if .IsNil() {
.Set(reflect.MakeSlice(, 0, 0))
}
:= reflect.Zero(.Elem())
.Set(reflect.Append(, ))
:= parse(.Index(.Len()-1), , "")
if != nil {
return
}
}
return nil
}
func ( reflect.Value, *XMLNode, reflect.StructTag) error {
if .IsNil() {
.Set(reflect.MakeMap(.Type()))
}
if .Get("flattened") == "" { // look at all child entries
for , := range .Children["entry"] {
parseMapEntry(, , )
}
} else { // this element is itself an entry
parseMapEntry(, , )
}
return nil
}
func ( reflect.Value, *XMLNode, reflect.StructTag) error {
, := "key", "value"
if := .Get("locationNameKey"); != "" {
=
}
if := .Get("locationNameValue"); != "" {
=
}
, := .Children[]
:= .Children[]
if {
for , := range {
:= reflect.ValueOf(.Text)
:= []
:= reflect.New(.Type().Elem()).Elem()
parse(, , "")
.SetMapIndex(, )
}
}
return nil
}
func ( reflect.Value, *XMLNode, reflect.StructTag) error {
switch .Interface().(type) {
case *string:
.Set(reflect.ValueOf(&.Text))
return nil
case []byte:
, := base64.StdEncoding.DecodeString(.Text)
if != nil {
return
}
.Set(reflect.ValueOf())
case *bool:
, := strconv.ParseBool(.Text)
if != nil {
return
}
.Set(reflect.ValueOf(&))
case *int64:
, := strconv.ParseInt(.Text, 10, 64)
if != nil {
return
}
.Set(reflect.ValueOf(&))
case *float64:
, := strconv.ParseFloat(.Text, 64)
if != nil {
return
}
.Set(reflect.ValueOf(&))
case *time.Time:
:= .Get("timestampFormat")
if len() == 0 {
= protocol.ISO8601TimeFormatName
}
, := protocol.ParseTime(, .Text)
if != nil {
return
}
.Set(reflect.ValueOf(&))
default:
return fmt.Errorf("unsupported value: %v (%s)", .Interface(), .Type())
}
return nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |