chore: save local changes (by AI)
This commit is contained in:
parent
cc1a7b04a9
commit
e1be66a59d
10
convert.go
10
convert.go
@ -66,7 +66,7 @@ func performConversion(source, destination any) *reflect.Value {
|
|||||||
if realDestination.CanAddr() {
|
if realDestination.CanAddr() {
|
||||||
address := realDestination.Addr().Interface()
|
address := realDestination.Addr().Interface()
|
||||||
if unmarshaler, isJSONUnmarshaler := address.(json.Unmarshaler); isJSONUnmarshaler {
|
if unmarshaler, isJSONUnmarshaler := address.(json.Unmarshaler); isJSONUnmarshaler {
|
||||||
_ = unmarshaler.UnmarshalJSON(cast.MustJsonBytes(realSource.Interface()))
|
_ = unmarshaler.UnmarshalJSON(cast.MustJSONBytes(realSource.Interface()))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if unmarshaler, isYAMLUnmarshaler := address.(yaml.Unmarshaler); isYAMLUnmarshaler {
|
if unmarshaler, isYAMLUnmarshaler := address.(yaml.Unmarshaler); isYAMLUnmarshaler {
|
||||||
@ -109,7 +109,7 @@ func performConversion(source, destination any) *reflect.Value {
|
|||||||
|
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
if destinationType.Elem().Kind() == reflect.Uint8 {
|
if destinationType.Elem().Kind() == reflect.Uint8 {
|
||||||
applyValue(realDestination, reflect.ValueOf(cast.MustJsonBytes(realSource.Interface())), &allocatedValue)
|
applyValue(realDestination, reflect.ValueOf(cast.MustJSONBytes(realSource.Interface())), &allocatedValue)
|
||||||
} else {
|
} else {
|
||||||
normalizedSource := realSource
|
normalizedSource := realSource
|
||||||
if sourceType.Kind() == reflect.String {
|
if sourceType.Kind() == reflect.String {
|
||||||
@ -122,7 +122,7 @@ func performConversion(source, destination any) *reflect.Value {
|
|||||||
normalizedSource = tempSlice
|
normalizedSource = tempSlice
|
||||||
} else {
|
} else {
|
||||||
var rawList []any
|
var rawList []any
|
||||||
cast.UnJson(sourceStr, &rawList)
|
cast.UnmarshalJSON(sourceStr, &rawList)
|
||||||
normalizedSource = reflect.ValueOf(rawList)
|
normalizedSource = reflect.ValueOf(rawList)
|
||||||
}
|
}
|
||||||
} else if sourceType.Kind() != reflect.Slice {
|
} else if sourceType.Kind() != reflect.Slice {
|
||||||
@ -141,7 +141,7 @@ func performConversion(source, destination any) *reflect.Value {
|
|||||||
convertStructToStruct(effectiveSource, realDestination)
|
convertStructToStruct(effectiveSource, realDestination)
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
var rawMap map[string]any
|
var rawMap map[string]any
|
||||||
cast.UnJson(effectiveSource.String(), &rawMap)
|
cast.UnmarshalJSON(effectiveSource.String(), &rawMap)
|
||||||
convertMapToStruct(reflect.ValueOf(rawMap), realDestination)
|
convertMapToStruct(reflect.ValueOf(rawMap), realDestination)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ func performConversion(source, destination any) *reflect.Value {
|
|||||||
convertStructToMap(realSource, realDestination)
|
convertStructToMap(realSource, realDestination)
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
var rawMap map[string]any
|
var rawMap map[string]any
|
||||||
cast.UnJson(realSource.String(), &rawMap)
|
cast.UnmarshalJSON(realSource.String(), &rawMap)
|
||||||
convertMapToMap(reflect.ValueOf(rawMap), realDestination)
|
convertMapToMap(reflect.ValueOf(rawMap), realDestination)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user