This commit is contained in:
crusader 2018-03-20 14:18:16 +09:00
parent 90166e94c5
commit 893e967fac

View File

@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"reflect"
cur "git.loafle.net/commons_go/util/reflect"
)
// SetValueWithJSONStringArray set the value of json string array
@ -35,8 +37,13 @@ func SetValueWithJSONStringArray(raw []byte, targets []interface{}) error {
case reflect.Ptr:
return fmt.Errorf("Type of target[%d] cannot be double ptr, value=%s", indexI, value)
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