From 1fa0d7510351c7b09e88c190e12bcea6186fc134 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 10 Apr 2018 17:37:50 +0900 Subject: [PATCH] ing --- encoding/json/json.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)) }