encoding/json: disable anonymous fields

We should, after Go 1, make them work the same as
package xml, that is, make them appear in the outer
struct.  For now turn them off so that people do not
depend on the old behavior.

Fixing them is issue 3069.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656102
This commit is contained in:
Russ Cox 2012-02-19 00:27:05 -05:00
parent 89b075cc90
commit 990f9f4c00
3 changed files with 48 additions and 0 deletions

View file

@ -538,6 +538,11 @@ func encodeFields(t reflect.Type) []encodeField {
if f.PkgPath != "" {
continue
}
if f.Anonymous {
// We want to do a better job with these later,
// so for now pretend they don't exist.
continue
}
var ef encodeField
ef.i = i
ef.tag = f.Name