fix(serialization): correctly handle json tag

This commit is contained in:
yusing
2025-10-12 20:59:12 +08:00
parent c66de99fcb
commit 5640d5d454

View File

@@ -211,6 +211,10 @@ func initTypeKeyFieldIndexesMap(t reflect.Type) typeInfo {
deserializeTag := field.Tag.Get(tagDeserialize) deserializeTag := field.Tag.Get(tagDeserialize)
jsonTag := field.Tag.Get(tagJSON) jsonTag := field.Tag.Get(tagJSON)
if jsonTag != "" {
jsonTag, _, _ = strings.Cut(jsonTag, ",")
}
if deserializeTag == "-" || jsonTag == "-" { if deserializeTag == "-" || jsonTag == "-" {
continue continue
} }
@@ -508,10 +512,10 @@ func ConvertString(src string, dst reflect.Value) (convertible bool, convErr gpe
} }
// Early return for empty string // Early return for empty string
if src == "" { if src == "" {
dst.SetZero() dst.SetZero()
return true, nil return true, nil
} }
switch dstT { switch dstT {
case reflect.TypeFor[time.Duration](): case reflect.TypeFor[time.Duration]():