Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*Node)
return false
}

fieldValue := modelValue.Field(i)
fieldType := modelType.Field(i)
tag := fieldType.Tag.Get("jsonapi")
if tag == "" {
i += 1
return false
}

i += 1
fieldValue := modelValue.Field(i)

tag := fieldType.Tag.Get("jsonapi")
i += 1

args := strings.Split(tag, ",")

Expand Down
14 changes: 9 additions & 5 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,21 @@ func visitModelNode(model interface{}, sideload bool) (*Node, []*Node, error) {

var i = 0
modelType.FieldByNameFunc(func(name string) bool {
fieldValue := modelValue.Field(i)
structField := modelType.Field(i)

i += 1
if er != nil {
return false
}

structField := modelType.Field(i)
tag := structField.Tag.Get("jsonapi")

if tag == "" {
i += 1
return false
}

fieldValue := modelValue.Field(i)

i += 1

args := strings.Split(tag, ",")

if len(args) != 2 {
Expand Down
1 change: 1 addition & 0 deletions response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Blog struct {
}

type Post struct {
Blog
Id int `jsonapi:"primary,posts"`
BlogId int `jsonapi:"attr,blog_id"`
Title string `jsonapi:"attr,title"`
Expand Down