mirror of
https://github.com/gin-gonic/gin.git
synced 2025-04-06 03:57:46 +08:00
Fix form mapping nullable types
This commit is contained in:
parent
205bb8151c
commit
2950dca3ce
@ -236,7 +236,20 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
|
|||||||
case time.Time:
|
case time.Time:
|
||||||
return setTimeField(val, field, value)
|
return setTimeField(val, field, value)
|
||||||
}
|
}
|
||||||
return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
|
|
||||||
|
err := json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ms, err := json.Marshal(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Unmarshal(ms, value.Addr().Interface())
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
|
return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user