In general if you have a service that only return a list, the first option is perfect fine:
[
{
"name": "Harry Potter",
"year": 2000
}
]
But if you are thinking in a general way to do it will be better add more context data, as total items counter, pagination variables or status values. So in spite of the first one is perfectly fine, I always preffer second one, but without the name of the collection/array/table name and with more context info, as for example:
{
"items": [
{
"name": "Harry Potter",
"year": 2000
}
],
"total": 1,
"page": 1,
"pages": 1
"status": 1,
"timestamp: 121344
}
Set the array nested on movies
value is a bit redundant. But for my it's only a practical approach that for my experience is more readable and used in all projects which I am related.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…