mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/json: don't match field name if a JSON struct tag is present.
Fixes #3566. R=rsc CC=golang-dev https://golang.org/cl/6139048
This commit is contained in:
parent
dae2992c98
commit
c3c8e35af2
2 changed files with 17 additions and 4 deletions
|
|
@ -504,10 +504,15 @@ func (d *decodeState) object(v reflect.Value) {
|
|||
}
|
||||
// First, tag match
|
||||
tagName, _ := parseTag(tag)
|
||||
if tagName == key {
|
||||
f = sf
|
||||
ok = true
|
||||
break // no better match possible
|
||||
if tagName != "" {
|
||||
if tagName == key {
|
||||
f = sf
|
||||
ok = true
|
||||
break // no better match possible
|
||||
}
|
||||
// There was a tag, but it didn't match.
|
||||
// Ignore field names.
|
||||
continue
|
||||
}
|
||||
// Second, exact field name match
|
||||
if sf.Name == key {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue