This repository was archived by the owner on Sep 4, 2025. It is now read-only.
Description Hi, I cant seems to create a response like the one bellow (origin JsonAPI site )
{
"meta" : {
"total-pages" : 13
},
"data" : [{
"type" : " articles" ,
"id" : " 3" ,
"attributes" : {
"title" : " JSON API paints my bikeshed!" ,
"body" : " The shortest article. Ever." ,
"created" : " 2015-05-22T14:56:29.000Z" ,
"updated" : " 2015-05-22T14:56:28.000Z"
}
}],
"links" : {
"self" : " http://example.com/articles?page[number]=3&page[size]=1" ,
"first" : " http://example.com/articles?page[number]=1&page[size]=1" ,
"prev" : " http://example.com/articles?page[number]=2&page[size]=1" ,
"next" : " http://example.com/articles?page[number]=4&page[size]=1" ,
"last" : " http://example.com/articles?page[number]=13&page[size]=1"
}
}
I can get the data but could not figure how to add meta or links to the response. I could only add them under the data level
This is the struct
type Album struct {
ID int `jsonapi:"primary,album"`
Name string `jsonapi:"attr,name"`
}
First I tried []*Album but coludnt understand how to add meta/links to the slice
Then I created a wrapper struct
type Albums struct {
Albums []* Album `jsonapi:"relation,albums"`
}
But the output was invalid (or at least not like the provided example)
What am I missing. How can I add meta/links to the top level. Thanks.
👍 React with 👍 1yas-okadatech