diff --git a/encoding/json/json.go b/encoding/json/json.go index df6258c..41a3e48 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -11,12 +11,16 @@ import ( // SetValueWithJSONStringArray set the value of json string array // raw([]byte) is ["1", {"a": 1}, [1, 2]] // targets([]interface{}) is array of pointer ex) *int, *string, *[], *map, *struct -func SetValueWithJSONStringArray(raw []byte, targets []interface{}) error { +func SetValueWithJSONStringArrayBytes(raw []byte, targets []interface{}) error { var values []string if err := json.Unmarshal(raw, &values); err != nil { return err } + return SetValueWithJSONStringArray(values, targets) +} + +func SetValueWithJSONStringArray(values []string, targets []interface{}) error { if len(targets) != len(values) { return fmt.Errorf("Count of raw[%d] and targets[%d] is not same", len(values), len(targets)) }