それらは違う。これが私のプロジェクトの例です。
試してGet http://localhost:3000/phone-numbers/1/relationships/contact
みると、次のような応答が得られます。
{
"links": {
"self": "http://localhost:3000/phone-numbers/1/relationships/contact",
"related": "http://localhost:3000/phone-numbers/1/contact"
},
"data": {
"type": "contacts",
"id": "1"
}
}
おそらく取得したい と を取得できませんでした。attributes
relationships
次に、試してGet http://localhost:3000/phone-numbers/1/contact
みると、次のような応答が得られます。
{
"data": {
"id": "1",
"type": "contacts",
"links": {
"self": "http://localhost:3000/contacts/1"
},
"attributes": {
"name-first": "John",
"name-last": "Doe",
"email": "john.doe@boring.test",
"twitter": null
},
"relationships": {
"phone-numbers": {
"links": {
"self": "http://localhost:3000/contacts/1/relationships/phone-numbers",
"related": "http://localhost:3000/contacts/1/phone-numbers"
}
}
}
}
}
attributes
とを含む、必要なすべての情報を取得したことがわかりますrelationships
。
relationships
しかし、それは何らかの目的に使用できることを知っておく必要があります。サンプルとしてhttp://jsonapi.org/format/#crud-updating-to-one-relationshipsをお読みください。