1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00

do not report error when field is unexported

This commit is contained in:
Tao Wen 2017-09-19 10:06:34 +08:00
parent 1f58120d43
commit faa3dcf46a

View File

@ -227,9 +227,6 @@ func describeStruct(cfg *frozenConfig, typ reflect.Type) (*StructDescriptor, err
bindings := []*Binding{}
for i := 0; i < typ.NumField(); i++ {
field := typ.Field(i)
if unicode.IsLower([]rune(field.Name)[0]) {
continue
}
tag := field.Tag.Get(cfg.getTagKey())
tagParts := strings.Split(tag, ",")
if tag == "-" {
@ -272,7 +269,7 @@ func describeStruct(cfg *frozenConfig, typ reflect.Type) (*StructDescriptor, err
if decoder == nil {
var err error
decoder, err = decoderOfType(cfg, field.Type)
if err != nil {
if len(fieldNames) > 0 && err != nil {
return nil, err
}
}
@ -280,11 +277,11 @@ func describeStruct(cfg *frozenConfig, typ reflect.Type) (*StructDescriptor, err
if encoder == nil {
var err error
encoder, err = encoderOfType(cfg, field.Type)
if err != nil {
if len(fieldNames) > 0 && err != nil {
return nil, err
}
// map is stored as pointer in the struct
if field.Type.Kind() == reflect.Map {
if encoder != nil && field.Type.Kind() == reflect.Map {
encoder = &optionalEncoder{encoder}
}
}