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{}
|
var models []interface{}
|
||||||
for _, data := range payload.Data {
|
for _, data := range payload.Data {
|
||||||
model := reflect.New(t)
|
model := reflect.New(t.Elem())
|
||||||
err := unmarshalNode(data, reflect.ValueOf(model), &includedMap)
|
err := unmarshalNode(data, model, &includedMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -214,6 +214,17 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*Node)
|
||||||
return false
|
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)) {
|
if fieldValue.Type() == reflect.TypeOf(new(time.Time)) {
|
||||||
var at int64
|
var at int64
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue