Anyone else dislike the new attributes from entities on a API request? There should be a way to toggle old structure

It forces you to write custom mapping logic on your consuming application since there are .attributes on everything, just to get the data. It’s especially brutal if you are trying to migrate a v3 app to a v4 app. I understand there’s a new structure but I can’t be the only one who wishes there was a way to toggle the new structure or old structure somewhere.

For clarification I wish this:

    "data": [
        {
            "id": 7,
            "attributes": {
                "title": "illustrations",
                "description": null,
                "createdAt": "2022-02-12T14:03:23.317Z",
                "updatedAt": "2022-02-12T14:03:23.317Z"
            }
        },
        {
            "id": 8,
            "attributes": {
                "title": "images",
                "description": null,
                "createdAt": "2022-02-12T14:06:55.316Z",
                "updatedAt": "2022-02-12T14:06:55.316Z"
            }
        },
        {
            "id": 9,
            "attributes": {
                "title": "icons",
                "description": null,
                "createdAt": "2022-02-12T14:06:55.331Z",
                "updatedAt": "2022-02-12T14:06:55.331Z"
            }
        }
    ],

Could go back to this:

  "data": [
        {
            "id": 7,
            "title": "illustrations",
            "description": null,
            "createdAt": "2022-02-12T14:03:23.317Z",
            "updatedAt": "2022-02-12T14:03:23.317Z"
        },
        {
            "id": 8,
            "title": "images",
            "description": null,
            "createdAt": "2022-02-12T14:06:55.316Z",
            "updatedAt": "2022-02-12T14:06:55.316Z"
        },
        {
            "id": 9,
            "title": "icons",
            "description": null,
            "createdAt": "2022-02-12T14:06:55.331Z",
            "updatedAt": "2022-02-12T14:06:55.331Z"
        }
    ],

Without having to write custom controllers to get the functionality.

2 Likes

I have also found it annoying. No solution for you though sorry, just agreeing!

It’s more like jsonapi specification but not same. You can try jsonapi deserializer to convert it to normal json.