diff --git a/encoding/json/json.go b/encoding/json/json.go index 52e056a..d0e8371 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -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