Skip to content

Unmarshalling of nested structs #99

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

Merged
merged 26 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e13a199
extract type handling
mrowdy Jul 10, 2017
ec077ed
Merge branch 'master' of https://github.com/Slemgrim/jsonapi
mrowdy Jul 10, 2017
f0b268e
Merge remote-tracking branch 'upstream/master'
mrowdy Jul 10, 2017
ab915cc
unify type handler
mrowdy Jul 10, 2017
0c97f0c
extract attribute handling into custom method for recursive usage lat…
mrowdy Jul 11, 2017
af21dba
handle nested struct slices
mrowdy Jul 15, 2017
b391a84
remove duplicated code
mrowdy Aug 14, 2017
fc6968d
change nested structs to json annotation instead of json:api. It neve…
mrowdy Aug 14, 2017
7e5c901
Merge remote-tracking branch 'upstream/master'
mrowdy Nov 21, 2017
a6577df
Add more speaking tests
mrowdy Nov 21, 2017
0400041
fix wrong type for formatting
mrowdy Nov 21, 2017
e3c0871
Test more things in TestUnmarshalNestedStruct
msabramo Jan 17, 2018
b28beab
Add TestUnmarshalNestedStructPtr
msabramo Jan 17, 2018
16e19ab
Make nested struct pointers work
msabramo Jan 17, 2018
a3b3bb2
Show type for ErrUnsupportedPtrType
msabramo Jan 17, 2018
339909d
Merge pull request #1 from msabramo/msabramo-pr-99
mrowdy Jan 22, 2018
bb266b4
Merge pull request #2 from msabramo/pr-99-show-type-for-ErrUnsupporte…
mrowdy Jan 22, 2018
21b4945
Merge pull request #3 from msabramo/pr-99-make-nested-struct-ptr-work
mrowdy Jan 22, 2018
7c2ceac
Fix test failures
msabramo Jan 25, 2018
e428b86
Merge pull request #4 from msabramo/fix-test-failures
mrowdy Jan 25, 2018
9bc94d8
replace public function with custom error type
Mar 14, 2018
72f7bad
check for ptr error type in tests
Mar 14, 2018
d490a0f
remove whitespaces and stick to 80chars
Mar 14, 2018
8b7e0bc
Merge pull request #5 from Slemgrim/refactor-ptr-error
mrowdy Mar 14, 2018
3c8221b
use jsonapi tags for nested attrs
shwoodard Sep 28, 2018
417d4eb
Merge pull request #6 from shwoodard/shwoodard-slemgrim-pull-99
mrowdy Oct 4, 2018
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
21 changes: 21 additions & 0 deletions models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,24 @@ func (bc *BadComment) JSONAPILinks() *Links {
"self": []string{"invalid", "should error"},
}
}

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

type Team struct {
Name string `jsonapi:"attr,name"`
Leader *Employee `jsonapi:"attr,leader"`
Members []Employee `jsonapi:"attr,members"`
}

type Employee struct {
Firstname string `jsonapi:"attr,firstname"`
Surname string `jsonapi:"attr,surname"`
Age int `jsonapi:"attr,age"`
HiredAt *time.Time `jsonapi:"attr,hired-at,iso8601"`
}
Loading