fix: unmarshal from number to string with incorrect error message (#3625)

This commit is contained in:
Kevin Wan
2023-10-15 10:06:00 +08:00
committed by GitHub
parent b731aa38af
commit 4f22034342
3 changed files with 15 additions and 5 deletions

View File

@@ -19,9 +19,10 @@ import (
)
const (
defaultKeyName = "key"
delimiter = '.'
ignoreKey = "-"
defaultKeyName = "key"
delimiter = '.'
ignoreKey = "-"
numberTypeString = "number"
)
var (
@@ -634,7 +635,7 @@ func (u *Unmarshaler) processFieldPrimitiveWithJSONNumber(fieldType reflect.Type
target.SetFloat(fValue)
default:
return newTypeMismatchErrorWithHint(fullName, typeKind.String(), value.Type().String())
return newTypeMismatchErrorWithHint(fullName, typeKind.String(), numberTypeString)
}
SetValue(fieldType, value, target)