forked from Mirrors/jsonapi
fix with included and handle string array value
This commit is contained in:
parent
00f3f5774e
commit
d336c1b556
15
request.go
15
request.go
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue