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