mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
6e03ed32c7
commit
f80d002438
3 changed files with 33 additions and 9 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue