如何在创建资源时提供要定义的多个资源?

How do I supply multiple resources to be defined when creating a resource?

查看示例:http://jsonapi.org/format/#crud-creating

如果我想指定多个 'photographers',我会把 'data' 属性 设为 array/collection 吗?

示例(来自上面的 link):

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" }
      }
    }
  }
}

这将是一个数组 - 请参阅复合文档的 example

"relationships": {
  "photographers": {
    "data": [
      { "type": "photographers", "id": "5" },
      { "type": "photographers", "id": "12" }
    ]
  }

注意 photographers 是复数。

如果您要包括任何实际的摄影师记录,它们将在 included 中,它位于 data 的顶层。