我正在使用 Api-Platform 为 AngularJs 应用程序构建我的第一个 rest API,
我想在这里获得我所有的项目实体,比如 juste(使用我的 url /projects):
{
"@context": "/contexts/Project",
"@id": "/projects",
"@type": "hydra:PagedCollection",
"hydra:totalItems": 19,
"hydra:itemsPerPage": 30,
"hydra:firstPage": "/projects",
"hydra:lastPage": "/projects",
"hydra:member": [
{
"@id": "/projects/1",
"@type": "Project",
"name": "test1",
"parent": null,
"createdAt": "2014-12-22T11:38:13+01:00",
"updatedAt": null,
"deletedAt": null
},
{
"@id": "/projects/2",
"@type": "Project",
"name": "test2",
"parent": null,
"createdAt": "2014-12-22T17:02:50+01:00",
"updatedAt": null,
"deletedAt": null
},
{
"@id": "/projects/3",
"@type": "Project",
"name": "test3",
"parent": "/projects/2",
"createdAt": "2014-12-22T18:28:50+01:00",
"updatedAt": null,
"deletedAt": null
}
]
}
但正如你所看到的,我的项目可以有父项目,所以我得到了我的父项目的参考(比如这个 /projects/2 )
我可以直接在 Json 中获取项目对象而不是像这样的引用吗?
{
"@id": "/projects/3",
"@type": "Project",
"name": "test3",
"parent": {
"@id": "/projects/2",
"@type": "Project",
"name": "test2",
"parent": null,
"createdAt": "2014-12-22T17:02:50+01:00",
"updatedAt": null,
"deletedAt": null
},
"createdAt": "2014-12-22T18:28:50+01:00",
"updatedAt": null,
"deletedAt": null
}
这是 Rest APi 的一个很好的实用性吗?