Skip to content

Commit 738c1fd

Browse files
authored
Merge pull request #28 from hashicorp/marshal_nested_object_attributes
Support nested objects within attributes when Marshaling
2 parents 1dc4f04 + 656e9ed commit 738c1fd

File tree

3 files changed

+430
-249
lines changed

3 files changed

+430
-249
lines changed

models_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,22 @@ type Company struct {
184184
ID string `jsonapi:"primary,companies"`
185185
Name string `jsonapi:"attr,name"`
186186
Boss Employee `jsonapi:"attr,boss"`
187+
Manager *Employee `jsonapi:"attr,manager"`
187188
Teams []Team `jsonapi:"attr,teams"`
188189
People []*People `jsonapi:"attr,people"`
189190
FoundedAt time.Time `jsonapi:"attr,founded-at,iso8601"`
190191
}
191192

193+
type CompanyOmitEmpty struct {
194+
ID string `jsonapi:"primary,companies"`
195+
Name string `jsonapi:"attr,name,omitempty"`
196+
Boss Employee `jsonapi:"attr,boss,omitempty"`
197+
Manager *Employee `jsonapi:"attr,manager,omitempty"`
198+
Teams []Team `jsonapi:"attr,teams,omitempty"`
199+
People []*People `jsonapi:"attr,people,omitempty"`
200+
FoundedAt time.Time `jsonapi:"attr,founded-at,iso8601,omitempty"`
201+
}
202+
192203
type People struct {
193204
Name string `jsonapi:"attr,name"`
194205
Age int `jsonapi:"attr,age"`

0 commit comments

Comments
 (0)