Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested objects within attributes when Marshaling #28

Merged
merged 3 commits into from
Jan 22, 2025
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
11 changes: 11 additions & 0 deletions models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,22 @@ type Company struct {
ID string `jsonapi:"primary,companies"`
Name string `jsonapi:"attr,name"`
Boss Employee `jsonapi:"attr,boss"`
Manager *Employee `jsonapi:"attr,manager"`
Teams []Team `jsonapi:"attr,teams"`
People []*People `jsonapi:"attr,people"`
FoundedAt time.Time `jsonapi:"attr,founded-at,iso8601"`
}

type CompanyOmitEmpty struct {
ID string `jsonapi:"primary,companies"`
Name string `jsonapi:"attr,name,omitempty"`
Boss Employee `jsonapi:"attr,boss,omitempty"`
Manager *Employee `jsonapi:"attr,manager,omitempty"`
Teams []Team `jsonapi:"attr,teams,omitempty"`
People []*People `jsonapi:"attr,people,omitempty"`
FoundedAt time.Time `jsonapi:"attr,founded-at,iso8601,omitempty"`
}

type People struct {
Name string `jsonapi:"attr,name"`
Age int `jsonapi:"attr,age"`
Expand Down
Loading
Loading