json: only use alphanumeric tags

Almost the same definition as Go identifier names.
(Leading digits are allowed.)

Fixes #1520.

R=r, r2
CC=golang-dev
https://golang.org/cl/4173061
This commit is contained in:
Russ Cox 2011-02-17 17:14:19 -05:00
parent 6e03ed32c7
commit f80d002438
3 changed files with 33 additions and 9 deletions

View file

@ -466,13 +466,15 @@ func (d *decodeState) object(v reflect.Value) {
} else {
var f reflect.StructField
var ok bool
// First try for field with that tag.
st := sv.Type().(*reflect.StructType)
for i := 0; i < sv.NumField(); i++ {
f = st.Field(i)
if f.Tag == key {
ok = true
break
// First try for field with that tag.
if isValidTag(key) {
for i := 0; i < sv.NumField(); i++ {
f = st.Field(i)
if f.Tag == key {
ok = true
break
}
}
}
if !ok {