Skip to content

Commit

Permalink
Merge pull request #28 from hashicorp/marshal_nested_object_attributes
Browse files Browse the repository at this point in the history
Support nested objects within attributes when Marshaling
  • Loading branch information
brandonc authored Jan 22, 2025
2 parents 1dc4f04 + 656e9ed commit 738c1fd
Show file tree
Hide file tree
Showing 3 changed files with 430 additions and 249 deletions.
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

0 comments on commit 738c1fd

Please sign in to comment.