mirror of
https://github.com/golang/go.git
synced 2025-11-08 12:41:02 +00:00
encoding/json: check for exported fields in embedded structs
Addresses issue #12367. Must be checked in before CL 14010. Change-Id: I7233c3a62d4f55d0ac7e8a87df5fc4ee7beb7207 Reviewed-on: https://go-review.googlesource.com/14011 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
3d198bd7be
commit
a30dd9ceeb
2 changed files with 15 additions and 3 deletions
|
|
@ -1021,7 +1021,7 @@ func typeFields(t reflect.Type) []field {
|
|||
// Scan f.typ for fields to include.
|
||||
for i := 0; i < f.typ.NumField(); i++ {
|
||||
sf := f.typ.Field(i)
|
||||
if sf.PkgPath != "" { // unexported
|
||||
if sf.PkgPath != "" && !sf.Anonymous { // unexported
|
||||
continue
|
||||
}
|
||||
tag := sf.Tag.Get("json")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue