mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 01:38:30 +02:00
fix(serialization): correctly handle json tag
This commit is contained in:
@@ -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]():
|
||||||
|
|||||||
Reference in New Issue
Block a user