使用嵌套对象序列化外键关联,例如:
{
"name": "service-production",
"owner": {
"id": "5d8201b0..."
},
// ...
}
而不是像这样:
{
"name": "service-production",
"owner_id": "5d8201b0...",
...
}
这种方式尽可能的把相关联的资源信息内联在一起,而不用改变资源的结构,或者引入更多的字段,例如:
{
"name": "service-production",
"owner": {
"id": "5d8201b0...",
"name": "Alice",
"email": "alice@heroku.com"
},
...
}