Skip to content

Commit bdc73a2

Browse files
authored
Merge pull request #99 from Slemgrim/master
Unmarshalling of nested structs
2 parents 3b9f84a + 417d4eb commit bdc73a2

File tree

3 files changed

+601
-237
lines changed

3 files changed

+601
-237
lines changed

models_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,24 @@ func (bc *BadComment) JSONAPILinks() *Links {
155155
"self": []string{"invalid", "should error"},
156156
}
157157
}
158+
159+
type Company struct {
160+
ID string `jsonapi:"primary,companies"`
161+
Name string `jsonapi:"attr,name"`
162+
Boss Employee `jsonapi:"attr,boss"`
163+
Teams []Team `jsonapi:"attr,teams"`
164+
FoundedAt time.Time `jsonapi:"attr,founded-at,iso8601"`
165+
}
166+
167+
type Team struct {
168+
Name string `jsonapi:"attr,name"`
169+
Leader *Employee `jsonapi:"attr,leader"`
170+
Members []Employee `jsonapi:"attr,members"`
171+
}
172+
173+
type Employee struct {
174+
Firstname string `jsonapi:"attr,firstname"`
175+
Surname string `jsonapi:"attr,surname"`
176+
Age int `jsonapi:"attr,age"`
177+
HiredAt *time.Time `jsonapi:"attr,hired-at,iso8601"`
178+
}

0 commit comments

Comments
 (0)