You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
body := `{"data":{"id":"1","type":"articles","attributes":{"title":"Hello World"}}}`
type Article struct {
ID string `jsonapi:"primary,articles"`
Title string `jsonapi:"attribute" json:"title"`
}
var a Article
err := jsonapi.Unmarshal([]byte(body), &a)
if err != nil {
panic(err)
}
fmt.Printf("%+v", &a)
// Output: &{ID:1 Title:Hello World}
}
func ExampleUnmarshal_slice() {
body := `{"data":[{"id":"1","type":"articles","attributes":{"title":"Hello World"}},{"id":"2","type":"articles","attributes":{"title":"Hello Again"}}]}`