1
0
mirror of https://github.com/json-iterator/go.git synced 2025-07-06 23:37:39 +02:00

#142 decode struct field should be case insensitive, the bug only happen for struct with more than 10 fields

This commit is contained in:
Tao Wen
2017-07-31 20:50:07 +08:00
parent c15b4d116c
commit 24ecaff2a1
4 changed files with 271 additions and 263 deletions

View File

@ -5,6 +5,7 @@ import (
"io"
"reflect"
"unsafe"
"strings"
)
func createStructDecoder(typ reflect.Type, fields map[string]*structFieldDecoder) (ValDecoder, error) {
@ -437,7 +438,7 @@ func (decoder *generalStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator)
for iter.nextToken() == ',' {
fieldBytes = iter.readObjectFieldAsBytes()
field = *(*string)(unsafe.Pointer(&fieldBytes))
fieldDecoder = decoder.fields[field]
fieldDecoder = decoder.fields[strings.ToLower(field)]
if fieldDecoder == nil {
iter.Skip()
} else {