TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Hacker News API doesn't obey RFC 4627

2 点作者 dmjio超过 10 年前
Normally, I would post this on the github issue tracker, but it does not exist. See https:&#x2F;&#x2F;github.com&#x2F;HackerNews&#x2F;API.<p>The API returns &quot;null&quot; when an &quot;Item&quot; doesn&#x27;t exist.<p>Example: https:&#x2F;&#x2F;hacker-news.firebaseio.com&#x2F;v0&#x2F;item&#x2F;1607092358902384905.json?print=pretty<p>RFC 4627 specifies that the returned JSON must be either an <i>object</i> or an <i>array</i>. This is neither. Please help. Thank you.<p>Suggestion: Instead of &quot;null&quot;, can you make it&quot;{ \&quot;item\&quot; : null }&quot; ?<p>Warmest Regards

3 条评论

kogir超过 10 年前
The API returns JSON values per RFC 4627 and RFC 7159. null is a valid value. This allows clients to request only what they want:<p>Entire item: <a href="https://hacker-news.firebaseio.com/v0/item/8422599.json" rel="nofollow">https:&#x2F;&#x2F;hacker-news.firebaseio.com&#x2F;v0&#x2F;item&#x2F;8422599.json</a><p>Just one property: <a href="https://hacker-news.firebaseio.com/v0/item/8422599/kids.json" rel="nofollow">https:&#x2F;&#x2F;hacker-news.firebaseio.com&#x2F;v0&#x2F;item&#x2F;8422599&#x2F;kids.json</a><p>Also, please send API correspondence to api@ycombinator.com.
MalcolmDiggs超过 10 年前
I&#x27;m more surprised that they&#x27;re returning a 200 when an item doesn&#x27;t exist. If they&#x27;d just return a 404, per usual, the content of the body wouldn&#x27;t really matter. (in my opinion)
评论 #8430193 未加载
评论 #8429256 未加载
zellio超过 10 年前
Isn&#x27;t null an object?
评论 #8429161 未加载