不要紧。这些字段在规范中标记为可选字段。很晚了。告我。
Q是供参考的。
接下来要说的是:
{
"tags": [
"cakephp",
"fileupload",
"file-get-contents"
],
"answer_count": 0,
"favorite_count": 0,
"question_timeline_url": "/questions/3078600/timeline",
"question_comments_url": "/questions/3078600/comments",
"question_answers_url": "/questions/3078600/answers",
"question_id": 3078600,
"owner": {
"user_id": 371434,
"user_type": "unregistered",
"display_name": "Nick",
"reputation": 1,
"email_hash": "2960026756b3103492382b68085207bd"
},
"creation_date": 1277021683,
"last_activity_date": 1277021683,
"up_vote_count": 0,
"down_vote_count": 0,
"view_count": 0,
"score": 0,
"community_owned": false,
"title": "How to retrieve contents from a uploaded file."
}失踪:
accepted_answer_id;
bounty_amount;
bounty_closes_date;
closed_date;
closed_reason;
migrated;
protected_date;如果它们被省略为可空,则应该考虑依赖于值的javascript客户端,以避免在对每个预期字段执行未定义的检查时出现极端的代码膨胀和性能问题。
如果它们被省略为可空,那么为什么不呈现其他0字段。不要误解我的意思,我只想问下一个合乎逻辑的问题。
发布于 2010-06-20 15:48:38
对于空字段和具有默认值的字段,要加以区分。
例如,在默认情况下,score是0。在概念上,它总是有一个值,所以它永远不会被省略。
默认情况下,accepted_answer_id是空的。因此,它不会返回,而不是填充0或-1或任何东西。
我还要指出,在javascript中检查默认值和不存在值的代码数量基本上是相同的。
if(question.accepted_answer_id == -1) ...对比
if(question.accepted_answer_id == undefined) ...我们目前的方案在带宽方面略好一些,在概念完整性方面则要好得多。返回中省略的字段是服务器对象上未定义的字段。
https://stackapps.com/questions/802
复制相似问题