请参阅此处的示例:http://jsonapi.org/format/#crud-creating
如果我想指定多位摄影师,我会制作数据'属性数组/集合?
示例(来自上面的链接):
POST /photos HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "photos",
"attributes": {
"title": "Ember Hamster",
"src": "http://example.com/images/productivity.png"
},
"relationships": {
"photographer": {
"data": { "type": "people", "id": "9" }
}
}
}
}
答案 0 :(得分:1)
这将是一个数组 - 请参阅复合文档的example。
"relationships": {
"photographers": {
"data": [
{ "type": "photographers", "id": "5" },
{ "type": "photographers", "id": "12" }
]
}
请注意photographers
是复数。
如果您要包含任何实际的摄影师记录,他们会在included
,data
处于最高级别。