From 893e967fac46ce4a52de94319928a637192b7aa5 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 20 Mar 2018 14:18:16 +0900 Subject: [PATCH] ing --- encoding/json/json.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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