嵌套外键关系
序列化的外键关系通常建立在一个有嵌套关系的对象之上, 例如.:
{
"name": "service-production",
"owner": {
"id": "5d8201b0..."
},
...
}
而不是这样 例如:
{
"name": "service-production",
"owner_id": "5d8201b0...",
...
}
这种方式尽可能的把相关联的资源信息内联在一起,而不用改变响应资源的结构,或者展示更高一级的响应区域, 例如:
{
"name": "service-production",
"owner": {
"id": "5d8201b0...",
"name": "Alice",
"email": "alice@heroku.com"
},
...
}