ing
This commit is contained in:
parent
90166e94c5
commit
893e967fac
|
@ -4,6 +4,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
cur "git.loafle.net/commons_go/util/reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetValueWithJSONStringArray set the value of json string array
|
// SetValueWithJSONStringArray set the value of json string array
|
||||||
|
@ -35,8 +37,13 @@ func SetValueWithJSONStringArray(raw []byte, targets []interface{}) error {
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
return fmt.Errorf("Type of target[%d] cannot be double ptr, value=%s", indexI, value)
|
return fmt.Errorf("Type of target[%d] cannot be double ptr, value=%s", indexI, value)
|
||||||
default:
|
default:
|
||||||
}
|
cv, err := cur.ConvertToType(value, reflect.TypeOf(target).Elem())
|
||||||
|
if nil != err {
|
||||||
|
return fmt.Errorf("Type conversion of value[%s] has been failed to %s[%d]", value, reflect.TypeOf(target).Elem().Kind(), indexI)
|
||||||
|
}
|
||||||
|
|
||||||
|
target = cv
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user