Source File
build.go
Belonging Package
github.com/aws/aws-sdk-go/private/protocol/json/jsonutil
if , := .Interface().(aws.JSONValue); ! {
= "map"
}
}
}
switch {
case "structure":
if , := .FieldByName("_"); {
= .Tag
}
return buildStruct(, , )
case "list":
return buildList(, , )
case "map":
return buildMap(, , )
default:
return buildScalar(, , )
}
}
func ( reflect.Value, *bytes.Buffer, reflect.StructTag) error {
if !.IsValid() {
return nil
}
:= .Field()
if .PkgPath != "" {
continue // ignore unexported fields
}
if .Tag.Get("json") == "-" {
continue
}
if .Tag.Get("location") != "" {
continue // ignore non-body elements
}
if .Tag.Get("ignore") != "" {
continue
}
if protocol.CanSetIdempotencyToken(, ) {
:= protocol.GetIdempotencyToken()
= reflect.ValueOf(&)
}
if (.Kind() == reflect.Ptr || .Kind() == reflect.Slice || .Kind() == reflect.Map) && .IsNil() {
continue // ignore unset fields
}
if {
= false
} else {
.WriteByte(',')
}
:= .Name
if := .Tag.Get("locationName"); != "" {
=
}
writeString(, )
.WriteString(`:`)
:= buildAny(, , .Tag)
if != nil {
return
}
}
.WriteString("}")
return nil
}
func ( reflect.Value, *bytes.Buffer, reflect.StructTag) error {
.WriteString("[")
for := 0; < .Len(); ++ {
buildAny(.Index(), , "")
if < .Len()-1 {
.WriteString(",")
}
}
.WriteString("]")
return nil
}
type sortedValues []reflect.Value
func ( sortedValues) () int { return len() }
func ( sortedValues) (, int) { [], [] = [], [] }
func ( sortedValues) (, int) bool { return [].String() < [].String() }
func ( reflect.Value, *bytes.Buffer, reflect.StructTag) error {
.WriteString("{")
:= sortedValues(.MapKeys())
sort.Sort()
for , := range {
if > 0 {
.WriteByte(',')
}
writeString(.String(), )
.WriteString(`:`)
buildAny(.MapIndex(), , "")
}
.WriteString("}")
return nil
}
:= [64]byte{}
switch := reflect.Indirect(); .Kind() {
case reflect.String:
writeString(.String(), )
case reflect.Bool:
if .Bool() {
.WriteString("true")
} else {
.WriteString("false")
}
case reflect.Int64:
.Write(strconv.AppendInt([:0], .Int(), 10))
case reflect.Float64:
:= .Float()
if math.IsInf(, 0) || math.IsNaN() {
return &json.UnsupportedValueError{Value: , Str: strconv.FormatFloat(, 'f', -1, 64)}
}
.Write(strconv.AppendFloat([:0], , 'f', -1, 64))
default:
switch converted := .Interface().(type) {
case time.Time:
:= .Get("timestampFormat")
if len() == 0 {
= protocol.UnixTimeFormatName
}
:= protocol.FormatTime(, )
if != protocol.UnixTimeFormatName {
= `"` + + `"`
}
.WriteString()
case []byte:
if !.IsNil() {
.WriteByte('"')
:= make([]byte, base64.StdEncoding.EncodedLen(len()))
base64.StdEncoding.Encode(, )
.Write()
:= base64.NewEncoder(base64.StdEncoding, )
.Write()
.Close()
}
.WriteByte('"')
}
case aws.JSONValue:
, := protocol.EncodeJSONValue(, protocol.QuotedEscape)
if != nil {
return fmt.Errorf("unable to encode JSONValue, %v", )
}
.WriteString()
default:
return fmt.Errorf("unsupported JSON value %v (%s)", .Interface(), .Type())
}
}
return nil
}
var hex = "0123456789abcdef"
func ( string, *bytes.Buffer) {
.WriteByte('"')
for := 0; < len(); ++ {
if [] == '"' {
.WriteString(`\"`)
} else if [] == '\\' {
.WriteString(`\\`)
} else if [] == '\b' {
.WriteString(`\b`)
} else if [] == '\f' {
.WriteString(`\f`)
} else if [] == '\r' {
.WriteString(`\r`)
} else if [] == '\t' {
.WriteString(`\t`)
} else if [] == '\n' {
.WriteString(`\n`)
} else if [] < 32 {
.WriteString("\\u00")
.WriteByte(hex[[]>>4])
.WriteByte(hex[[]&0xF])
} else {
.WriteByte([])
}
}
.WriteByte('"')
}
![]() |
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. |