I’m building a REST API with Yii2. Normally the request response looks something like this:
{
"items": [
{
"id": 1,
...
},
{
"id": 2,
...
},
...
],
"_links": {
"self": {
"href": "http://localhost/users?page=1"
},
"next": {
"href": "http://localhost/users?page=2"
},
"last": {
"href": "http://localhost/users?page=50"
}
},
"_meta": {
"totalCount": 1000,
"pageCount": 50,
"currentPage": 1,
"perPage": 20
}
}
I want to override the serializer so that the fields contained in the "_meta" array are instead included in the root of the array, i.e. the same level as "items" and "_links". How and where do I do that?
Thank you.