是否存在从API构建JSON响应的标准或最佳实践?显然,每个应用程序的数据都是不同的,所以我不关心这些,而是关心“响应样板”,如果你愿意的话。我的意思的一个例子:
请求成功:
{"success": true,"payload": {/* Application-specific data would go here. */}}
请求失败
{"success": false,"payload": {/* Application-specific data would go here. */},"error": {"code": 123,"message": "An error occurred!"}}