Search…
Data Transfer Objects
Data transfer objects, or DTOs, are objects used to wrap resource definitions in request/response objects along with additional information.
In a response body, you should return a JSON object, not an array, as a top level data structure to support future extensibility. This would allow you to extend your response and, for example, add a server side pagination attribute.
Bad response body
1
[
2
{ "id": "1", "name": "Einar" },
3
{ "id": "2", "name": "Erlendur"},
4
{ "id": "3", "name": "Valdimar"}
5
]
Copied!
Good response body
1
{
2
"users":[
3
{ "id": "1001", "name": "Einar"},
4
{ "id": "1002", "name": "Erlendur"},
5
{ "id": "1003", "name": "Valdimar"},
6
]
7
}
Copied!
Last modified 3mo ago
Copy link