mirror of
https://github.com/json-iterator/go.git
synced 2024-11-27 08:30:57 +02:00
fix tag field name not used bug
This commit is contained in:
parent
c7d0dd5b66
commit
e7ec3988a6
@ -713,12 +713,16 @@ func decoderOfStruct(type_ reflect.Type) (Decoder, error) {
|
||||
}
|
||||
decoder := fieldDecoders[fieldDecoderKey]
|
||||
tagParts := strings.Split(field.Tag.Get("json"), ",")
|
||||
// if fieldNames set by extension, use theirs, otherwise try tags
|
||||
if fieldNames == nil {
|
||||
/// tagParts[0] always present, even if no tags
|
||||
switch tagParts[0] {
|
||||
case "":
|
||||
fieldNames = []string{field.Name}
|
||||
case "-":
|
||||
fieldNames = []string{}
|
||||
default:
|
||||
fieldNames = []string{tagParts[0]}
|
||||
}
|
||||
}
|
||||
if decoder == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user