A Mason document has to be an object in order to include @links and other properties. So to return an array you have to wrap it in an object:
{
"items": [
{ ... item 1 ... },
{ ... item 2 ... },
...
],
"@links":
{ ... }
}
Mason does not impose any restrictions on the API data format and have no abstraction for "embedded" items like for instance HAL does. If you have embedded items then you can simply give them their own "self" link:
{
"items": [
{
"title": "This is item 1",
"@links": {
"self": { "href": "...", title: "Link to item 1" }
}
},
{
"title": "This is item 2",
"@links": {
"self": { "href": "...", title: "Link to item 2" }
}
}
],
"@links":
{ ... }
}
Wrapping the array in an object allows you to add other properties to the collection of items, for instance pagination and some developer information:
{
"@meta": {
"@description": "This is a collection of items. You can look for "next" and "prev" links for pagination."
}
"page": 1,
"items": [
{ ... item 1 ... },
{ ... item 2 ... },
...
],
"@links":
{
"next": { href: "..." },
// No "previous" link since its the first page
}
}
Regards, Jørn