diff options
Diffstat (limited to 'src/encoding/json/encode.go')
| -rw-r--r-- | src/encoding/json/encode.go | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go index 0522c43495..1e45e445d9 100644 --- a/src/encoding/json/encode.go +++ b/src/encoding/json/encode.go @@ -1094,18 +1094,11 @@ func typeFields(t reflect.Type) []field { isUnexported := sf.PkgPath != "" if sf.Anonymous { t := sf.Type - isPointer := t.Kind() == reflect.Ptr - if isPointer { + if t.Kind() == reflect.Ptr { t = t.Elem() } - isStruct := t.Kind() == reflect.Struct - if isUnexported && (!isStruct || isPointer) { - // Ignore embedded fields of unexported non-struct types - // or pointers to unexported struct types. - // - // The latter is forbidden because unmarshal is unable - // to assign a new struct to the unexported field. - // See https://golang.org/issue/21357 + if isUnexported && t.Kind() != reflect.Struct { + // Ignore embedded fields of unexported non-struct types. continue } // Do not ignore embedded fields of unexported struct types |
