Ответ 1
из http://jsonapi.org/format/#document-compound-documents
Составные документы требуют "полной привязки", что означает, что каждый включенный ресурс ДОЛЖЕН быть идентифицирован по меньшей мере одним объектом идентификатора ресурса в том же документе. Эти объекты идентификатора ресурса могли либо быть первичными данными или представлять связь с ресурсами, содержащуюся в или включены ресурсы. Единственное исключение из полной связи Требование - это когда поля отношений, которые в противном случае содержали бы данные привязки исключаются через разреженные поля.
{
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"links": {
"self": "http://example.com/articles/1"
},
"relationships": {
"author": {
"links": {
"self": "http://example.com/articles/1/relationships/author",
"related": "http://example.com/articles/1/author"
},
"data": { "type": "people", "id": "9" }
},
"comments": {
"links": {
"self": "http://example.com/articles/1/relationships/comments",
"related": "http://example.com/articles/1/comments"
},
"data": [
{ "type": "comments", "id": "5" },
{ "type": "comments", "id": "12" }
]
}
}
}],
"included": [{
"type": "people",
"id": "9",
"attributes": {
"first-name": "Dan",
"last-name": "Gebhardt",
"twitter": "dgeb"
},
"links": {
"self": "http://example.com/people/9"
}
}, {
"type": "comments",
"id": "5",
"attributes": {
"body": "First!"
},
"links": {
"self": "http://example.com/comments/5"
}
}, {
"type": "comments",
"id": "12",
"attributes": {
"body": "I like XML better"
},
"links": {
"self": "http://example.com/comments/12"
}
}]
}