我正在查看 Active Model Serializer 的 README 并查看以下示例:
render json: @posts, serializer: CustomArraySerializer, meta: {total: 10}, meta_key: 'meta_object'
...
{
"meta_object": { "total": 10 },
"posts": [
{ "title": "Post 1", "body": "Hello!" },
{ "title": "Post 2", "body": "Goodbye!" }
]
}
但我希望能够输出:
{
"meta_object": { "total": 10 },
"sort":[2,1],
"posts": [
{ "title": "Post 1", "body": "Hello!" },
{ "title": "Post 2", "body": "Goodbye!" }
]
}
我猜我需要有两个元对象。这可能吗?我该怎么做?