You've already forked json-iterator
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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user