aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/encode.go
diff options
context:
space:
mode:
authorMarcel van Lohuizen <mpvl@golang.org>2015-08-28 10:17:05 +0200
committerMarcel van Lohuizen <mpvl@golang.org>2015-10-26 11:23:31 +0000
commita30dd9ceeb2fb2361cd5a4ae623258ec0a96c517 (patch)
treedea157696f6e24222c8711942480fc7e77a0b67d /src/encoding/json/encode.go
parent3d198bd7be771ed0722af577eef840b24d62374a (diff)
downloadgo-a30dd9ceeb2fb2361cd5a4ae623258ec0a96c517.tar.xz
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>
Diffstat (limited to 'src/encoding/json/encode.go')
-rw-r--r--src/encoding/json/encode.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go
index 60d1c9011b..6af2fabeb4 100644
--- a/src/encoding/json/encode.go
+++ b/src/encoding/json/encode.go
@@ -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")