问题
I am using the get folder items API call, and I can tell from my tests that the order appears to be folders first and then alphabetical.
Is this call guaranteed to always return items in that order?
回答1:
Box Platform team member here ... we do not consider the order of the results returned by any of our collections endpoints part of their public contract and they are subject to change. For GET /folders/id/items at least, the JSON response includes an order
array, which shows how the response is ordered.
{
"total_count": 6,
"entries": [
{
"type": "folder",
"id": "192429928",
"sequence_id": "1",
"etag": "1",
"name": "Lebron and Friends"
},
{
"type": "folder",
"id": "192429929",
"sequence_id": "1",
"etag": "1",
"name": "Stephen Curry Three Pointers"
},
{
"type": "file",
"id": "818853864",
"sequence_id": "0",
"etag": "0",
"name": "Heat.jpg"
},
{
"type": "file",
"id": "818853862",
"sequence_id": "0",
"etag": "0",
"name": "Warriors.jpg"
}
],
"offset": 0,
"limit": 4,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}
Note that this response can also include web links.
If your app depends on the list of items being ordered a certain way, we recommend sorting on the client.
来源:https://stackoverflow.com/questions/19547380/ordering-of-get-folder-items-api-call