ing
This commit is contained in:
parent
1cf977be25
commit
1fa0d75103
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user