fix with included and handle string array value

This commit is contained in:
Sam Woodard 2015-10-28 10:08:50 -07:00
parent 00f3f5774e
commit d336c1b556
1 changed files with 13 additions and 2 deletions

View File

@ -82,8 +82,8 @@ func UnmarshalManyPayload(in io.Reader, t reflect.Type) ([]interface{}, error) {
var models []interface{}
for _, data := range payload.Data {
model := reflect.New(t)
err := unmarshalNode(data, reflect.ValueOf(model), &includedMap)
model := reflect.New(t.Elem())
err := unmarshalNode(data, model, &includedMap)
if err != nil {
return nil, err
}
@ -214,6 +214,17 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*Node)
return false
}
if fieldValue.Type() == reflect.TypeOf([]string(nil)) {
values := make([]string, v.Len())
for i := 0; i < v.Len(); i++ {
values[i] = v.Index(i).Interface().(string)
}
fieldValue.Set(reflect.ValueOf(values))
return false
}
if fieldValue.Type() == reflect.TypeOf(new(time.Time)) {
var at int64