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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

JSON Feed

486 点作者 fold大约 8 年前

28 条评论

mstade大约 8 年前
&gt; JSON Feed files must be served using the same MIME type — application&#x2F;json — that’s used whenever JSON is served.<p>So then it&#x27;s JSON, and I&#x27;ll treat it as any other JSON: a document that is either an object or an array, that can include other objects or arrays, as well as numbers and strings. Property names doesn&#x27;t matter, nor do order of properties or array items, or whatever values are contained therein.<p>Please don&#x27;t try to overload media types like this. Atom isn&#x27;t served as `application&#x2F;xml` precisely because it <i>isn&#x27;t</i> XML; it&#x27;s served as `application&#x2F;atom+xml`. For a media type that is JSON-like but isn&#x27;t JSON, you may wish to look at `application&#x2F;hal+json`; incidentally there&#x27;s also `application&#x2F;hal+xml` for the XML variant.<p>Or as someone else rightly suggested, consider just using JSON-LD.
评论 #14361418 未加载
评论 #14365671 未加载
评论 #14363176 未加载
评论 #14362699 未加载
评论 #14363312 未加载
评论 #14361769 未加载
mindcrime大约 8 年前
Do we really need this? Atom is fine for feeds. Avoiding XML just for the sake of avoiding XML, because it isn&#x27;t &quot;cool&quot; anymore is just dump groupthink.<p>If this industry has a problem, it&#x27;s FDD - Fad Driven Development and IIICIS (If It Isn&#x27;t Cool, It Sucks) thinking.
评论 #14361493 未加载
评论 #14361395 未加载
评论 #14361178 未加载
评论 #14361367 未加载
评论 #14362133 未加载
评论 #14361386 未加载
评论 #14361977 未加载
评论 #14366076 未加载
评论 #14364580 未加载
评论 #14364633 未加载
评论 #14364045 未加载
评论 #14363826 未加载
评论 #14362520 未加载
评论 #14361051 未加载
russellbeattie大约 8 年前
For anyone who&#x27;s tried to write a real-world RSS feed reader, this format does little to solve the big problems the newsfeeds have:<p>* Badly formed XML? Check. There might be badly formed JSON, but I tend to think it&#x27;ll be a lot less likely.<p>* Need to continually poll servers for updates? Miss. Without additions to enable pubsub, or dynamic queries, clients are forced to use HTTP headers to check last updates, then do a delta on the entire feed if there is new or updated content. Also, if you missed 10 updates, and the feed only contains the last 5 items, then you lose information. This is the nature of a document-centric feed meant to be served as a static file. But it&#x27;s 2017 now, and it&#x27;s incredibly rare that a feed isn&#x27;t created dynamically. A new feed spec should incorporate that reality.<p>* Complete understanding of modern content types besides blog posts? Miss. The last time I went through a huge list of feeds for testing, I found there were over 50 commonly used namespaces and over 300 unique fields used. RSS is used for <i>everything</i> from search results to Twitter posts to Podcasts... It&#x27;s hard to describe all the different forms of data it can be contain. The reason for this is because the original RSS spec was so minimal (there&#x27;s like 5 required fields) so everything else has just been bolted on. JSONFeed makes this same mistake.<p>* An understanding that separate but equal isn&#x27;t equal. Miss. The thing that <a href="http:&#x2F;&#x2F;activitystrea.ms" rel="nofollow">http:&#x2F;&#x2F;activitystrea.ms</a> got right was the realization that copying content into a feed just ends up diluting the original content formatting, so instead it just contains metadata and points to the original source URL rather than trying to contain it. If JSONFeed wanted to really create a successor to RSS, it would spec out how to send along formatting information along with the data. It&#x27;s not impossible - look at what Google did with AMP: They specified a subset of formatting options so that each article can still contain a unique design, but limited the options to increase efficiency and limit bugs&#x2F;chaos.<p>This stuff is just off the top of my head. If you&#x27;re going to make a new feed format in 2017, I&#x27;m sorry but copying what came before it and throwing it into JSON just isn&#x27;t enough.
评论 #14362350 未加载
评论 #14362449 未加载
评论 #14363633 未加载
评论 #14363433 未加载
CharlesW大约 8 年前
Dave Winer (the creator of RSS) played with this a bit in 2012. It turns out that exact format of feeds doesn&#x27;t matter nearly as much as there being a more-or-less universal one.<p><a href="http:&#x2F;&#x2F;scripting.com&#x2F;stories&#x2F;2012&#x2F;09&#x2F;10&#x2F;rssInJsonForReal.html" rel="nofollow">http:&#x2F;&#x2F;scripting.com&#x2F;stories&#x2F;2012&#x2F;09&#x2F;10&#x2F;rssInJsonForReal.htm...</a>
评论 #14363429 未加载
gedrap大约 8 年前
But does it solve any actual problems other than &#x27;XML is not cool&#x27;, problems big enough to deserve a new format?<p>It&#x27;s true that JSON is easier to deal with than XML. But that&#x27;s relative, there are plenty of decent tools around RSS. From readers, to libraries in the most common programming languages, and extensions in the most common content management systems. JSON is slightly easier to read for human (although that&#x27;s subjective), but then how often do you need to read the RSS feed manually, unless you are the one who is writing those libraries, etc. But that&#x27;s a tiny share of all people using RSS.<p>&gt;&gt;&gt; It reflects the lessons learned from our years of work reading and publishing feeds.<p>Sounds like the author(s) has extensive experience in this field and knows things better than some random person on the internet (me). But the homepage of the project doesn&#x27;t convey those learned lessons.
评论 #14361636 未加载
zeveb大约 8 年前
If we&#x27;re going to talk about replacing XML with better data formats, why not switch to S-expressions?<p><pre><code> (feed (version https:&#x2F;&#x2F;jsonfeed.org&#x2F;version&#x2F;1) (title &quot;My Example Feed&quot;) (home-page-url https:&#x2F;&#x2F;example.org) (feed-url https:&#x2F;&#x2F;example.org&#x2F;feed.json) (items (item (id 2) (content-text &quot;This is a second item.&quot;) (url https:&#x2F;&#x2F;example.org&#x2F;second-item)) (item (id 1) (content-html &quot;&lt;p&gt;Hello, world!&lt;&#x2F;p&gt;&quot;) (url https:&#x2F;&#x2F;example.org&#x2F;initial-post)))) </code></pre> This looks much nicer IMHO than their first example:<p><pre><code> { &quot;version&quot;: &quot;https:&#x2F;&#x2F;jsonfeed.org&#x2F;version&#x2F;1&quot;, &quot;title&quot;: &quot;My Example Feed&quot;, &quot;home_page_url&quot;: &quot;https:&#x2F;&#x2F;example.org&#x2F;&quot;, &quot;feed_url&quot;: &quot;https:&#x2F;&#x2F;example.org&#x2F;feed.json&quot;, &quot;items&quot;: [ { &quot;id&quot;: &quot;2&quot;, &quot;content_text&quot;: &quot;This is a second item.&quot;, &quot;url&quot;: &quot;https:&#x2F;&#x2F;example.org&#x2F;second-item&quot; }, { &quot;id&quot;: &quot;1&quot;, &quot;content_html&quot;: &quot;&lt;p&gt;Hello, world!&lt;&#x2F;p&gt;&quot;, &quot;url&quot;: &quot;https:&#x2F;&#x2F;example.org&#x2F;initial-post&quot; } ] }</code></pre>
评论 #14363567 未加载
评论 #14362293 未加载
评论 #14365895 未加载
评论 #14364609 未加载
评论 #14362224 未加载
评论 #14365443 未加载
Communitivity大约 8 年前
It is worth pointing out that there is a relevant W3C Recommendation &quot;JSON Activity Streams&quot;, <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;activitystreams-core&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;activitystreams-core&#x2F;</a> . I&#x27;m not saying JSON Feed is worse, or better. I am saying that I think JSON Feeds adoption requires a detailed comparison between JSONFeed and JSON Activity Streams 2.0.
评论 #14364455 未加载
eric_the_read大约 8 年前
A few thoughts on the spec itself:<p>* In all cases (feed and items), the author field should be an array to allow for feeds with more than one author (for instance, a podcast might want to use this field for each of its hosts, or possibly even guests).<p>* external_url should probably be an array, too, in case you want to refer to multiple external resources about a specific topic, or in the case of a linkblog or podcast that discusses multiple topics, it could link to each subtopic.<p>* It might be nice if an item&#x27;s ID could be enforced to a specific format, even if perhaps only within a single feed. Otherwise it&#x27;s hard to know how to interpret posts with IDs like &quot;potato&quot;, 1, null, &quot;<a href="http:&#x2F;&#x2F;cheez.burger&#x2F;arghlebarghle&quot;" rel="nofollow">http:&#x2F;&#x2F;cheez.burger&#x2F;arghlebarghle&quot;</a>
评论 #14364058 未加载
评论 #14363421 未加载
jerf大约 8 年前
I would suggest specifying titles as html, not plain text. I&#x27;ve seen too many things titled &quot;I &lt;i&gt;love&lt;&#x2F;i&gt; science!&quot; over the years to believe in the idea that titles are plain text.<p>Also, despite the fact this is technically not the responsibility of the spec itself, I would <i>strongly</i> suggest some words on the implications of the fact that the HTML fields are indeed HTML and the wisdom of passing them through some sort of HTML filter before displaying them.<p>In fact that&#x27;s also part of why I suggest going ahead and letting titles contain HTML. All HTML is going to need to be filtered anyhow, and it&#x27;s OK for clients to filter titles to a smaller valid tag list, or even filter out all tags. Suggesting (but not mandating) a very basic list of tags for that field might be a good compromise.
评论 #14361551 未加载
评论 #14362472 未加载
jawns大约 8 年前
&gt; It&#x27;s at version 1, which may be the only version ever needed.<p>Wow. Now that&#x27;s confidence. Have you ever read the first version of a spec and thought, &quot;That&#x27;s just perfect. Any additional changes would just be a disappointment compared with the original&quot;?
评论 #14362055 未加载
评论 #14363037 未加载
评论 #14362249 未加载
评论 #14361572 未加载
pimlottc大约 8 年前
&gt; JSON is simpler to read and write, and it’s less prone to bugs.<p>Less prone to bugs? How&#x27;s that?
评论 #14361149 未加载
评论 #14361070 未加载
评论 #14361060 未加载
评论 #14361056 未加载
评论 #14361071 未加载
ttepasse大约 8 年前
Shortly after RSS 0.9 came out RSS 1.0 reformulated the RSS vocabulary in RDF terms. Of course the modern (sane) successor to RDF&#x2F;XML is JSON-LD.<p>So I&#x27;m hoping for JSON-LD Feed 1.1 and a new war of format battles. Maybe we can even get Mark Pilgrim out of hiding!
评论 #14363832 未加载
einrealist大约 8 年前
If you create a new JSON-based document format, please consider to use JSON-LD (aside raw JSON data) so we can make a true world of interconnected data through semantic formats. At least, so I can generate code and automatically validate format compatibility from a well-defined schema. Thank you!<p>EDIT: Because I get downvoted despite stating my opinion on the topic, I adjusted the statement.
评论 #14361167 未加载
gwu78大约 8 年前
Is this a &quot;JSON Feed&quot; from NYTimes?<p>Example below filters out all URLs for a specific section of the paper.<p><pre><code> test $# = 1 ||exec echo usage: $0 section curl -o 1.json https:&#x2F;&#x2F;static01.nyt.com&#x2F;services&#x2F;json&#x2F;sectionfronts&#x2F;$1&#x2F;index.jsonp exec sed &#x27;&#x2F;\&quot;guid\&quot; :&#x2F;!d;s&#x2F;\&quot;,&#x2F;&#x2F;;s&#x2F;.*\&quot;&#x2F;&#x2F;&#x27; 1.json </code></pre> I guess SpiderBytes could be used for older articles?<p>Personally, I think a protocol like netstrings&#x2F;bencode is better than JSON because it better respects the memory resources of the user&#x27;s computer.<p>Every proposed protocol will have tradeoffs.<p>To me, RAM is sacred. I can &quot;parse&quot; netstrings in one pass but I have been unable to do this with a state machine for JSON. I have to arbitrarily limit the number of states or risk a crash. As easy as it is to exhaust a user&#x27;s available RAM with Javascript so too can this be done with JSON. Indeed they go well together.
pedalpete大约 8 年前
&quot;JSON has become the developers’ choice for APIs&quot;, I&#x27;m curious about how people feel about this statement from a creation vs consumption perspective.<p>I&#x27;m currently creating an API where I&#x27;m asking devs to post JSON rather than a bunch of separate parameters, but I haven&#x27;t seen this done in other APIs (if you have, can you point me to a few examples?). I&#x27;m curious what others thoughts are on this. It seems that with GraphQl, we&#x27;re maybe starting to move in this direction.
smilbandit大约 8 年前
I&#x27;d like to see a language available at the item level. You can derive the language from the http headers but if you&#x27;re dealing with linkblogs it would be nice at the item level to help with filtering.<p>I think that images and urls would do well as order lists rather than as individual values. at the top level you have 3 urls and an array for hubs. with type and url you could have an array for hubs and the urls. same could be done for images at the top level and both again at the item level.
niftich大约 8 年前
It&#x27;s unfortunate that XML has fallen so out of favor that well-made, strongly-schemad formats specified in XML, like Atom, are suffering in turn -- although reasons for feeds&#x27; demise go well beyond its forms-on-the-wire. This trend frustrates me, but it&#x27;s undeniable that a lot of web data interchange happens with JSON-based formats nowadays, and the benefits of network effects, familiarity, and tooling support make JSONification worth exploring.<p>But even more frustrating is when a format comes out that&#x27;s close to being a faithful translation of an established format, but makes small, incompatible changes that push the burden of faithful translation onto content authors, or the makers of third-party libraries.<p>I honestly don&#x27;t intend to offer harsh targeted critique against the authors -- I assume good faith; more just voicing exasperation. There have been similar attempts over the years -- one from Dave Winer, the creator of RSS 0.92 and RSS 2.0, called RSS.js [1], which stoked some interest at first [2]; others by devs working in isolation without seeming access to a search engine and completely unaware of prior art; some who are just trying something unrelated and accidentally produce something usable [3]; finally, this question pops up from time to time on forums where people with an interest in this subject tend to congregate [4]. Meanwhile, real standards-bodies are off doing stuff that reframes the problem entirely [5] -- which seems out-of-touch at first, but I&#x27;d argue provides a better approach than similar-but-not-entirely-compatible riff on something really old.<p>And as a meta, &quot;people who use JSON-based formats&quot;, as a loose aggregate, have a serious and latent disagreement about whether data should have a schema or even a formal spec. In the beginning when people first started using JSON instead of XML, it was done in a schemaless way, and making sense of it was strictly best-effort on part of the receiving party. Then a movement appeared to bring schemas to JSON, which went against the original reason for using JSON in the first place, and now we&#x27;re stuck with the two camps playing in the same sandbox whose views, use-cases, and goals are contradictory. This appears to be a &quot;classic&quot; loose JSON format, not a strictly-schemad JSON format, not even bothering to declare its own mediatype. This invites criticism from the other camp, yet the authors are clearly not playing in that arena. What&#x27;s the long-term solution here?<p>[1] <a href="http:&#x2F;&#x2F;scripting.com&#x2F;stories&#x2F;2012&#x2F;09&#x2F;10&#x2F;rssInJsonForReal.html" rel="nofollow">http:&#x2F;&#x2F;scripting.com&#x2F;stories&#x2F;2012&#x2F;09&#x2F;10&#x2F;rssInJsonForReal.htm...</a> [2] <a href="https:&#x2F;&#x2F;core.trac.wordpress.org&#x2F;ticket&#x2F;25639" rel="nofollow">https:&#x2F;&#x2F;core.trac.wordpress.org&#x2F;ticket&#x2F;25639</a> [3] <a href="http:&#x2F;&#x2F;www.giantflyingsaucer.com&#x2F;blog&#x2F;?p=3521" rel="nofollow">http:&#x2F;&#x2F;www.giantflyingsaucer.com&#x2F;blog&#x2F;?p=3521</a> [4] <a href="https:&#x2F;&#x2F;groups.google.com&#x2F;forum&#x2F;#!topic&#x2F;restful-json&#x2F;gkaZl3AtiPk" rel="nofollow">https:&#x2F;&#x2F;groups.google.com&#x2F;forum&#x2F;#!topic&#x2F;restful-json&#x2F;gkaZl3A...</a> [5] <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;activitystreams-core&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;activitystreams-core&#x2F;</a>
0x006A大约 8 年前
why is it size_in_bytes and duration_in_seconds as opposed to content_text and content_html<p>It should just be size and duration or size_bytes size_seconds (but adding units only makes sense if you could use other units). adding _in to the mix is strange.
gumby大约 8 年前
A good announcement explains what problem it is intending to solve.
bullen大约 8 年前
I miss the distributed social pingback days!<p>Implemented: <a href="http:&#x2F;&#x2F;sprout.rupy.se&#x2F;feed?json" rel="nofollow">http:&#x2F;&#x2F;sprout.rupy.se&#x2F;feed?json</a>
voidfiles大约 8 年前
This seems like a great idea. If it can help even one developer it&#x27;s worth it.
评论 #14361168 未加载
cocktailpeanuts大约 8 年前
Doesn&#x27;t Wordpress already have something like this? <a href="http:&#x2F;&#x2F;v2.wp-api.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;v2.wp-api.org&#x2F;</a><p>I don&#x27;t understand why suddenly people treat this like something that uniquely solves a problem. Maybe I&#x27;m missing something?
评论 #14366144 未加载
ozten大约 8 年前
XML is aweful, but it does have CDATA, which lets you embed blog posts directly and it&#x27;s easy to debug.<p>String encoded blog posts are going to be painful once people start using the `content_html` part of the spec.
评论 #14364545 未加载
pswenson大约 8 年前
i&#x27;m surprised no one has started a snake vs camel case debate here! <a href="https:&#x2F;&#x2F;jsonfeed.org&#x2F;version&#x2F;1" rel="nofollow">https:&#x2F;&#x2F;jsonfeed.org&#x2F;version&#x2F;1</a>
nilved大约 8 年前
Good lord, Web people, stop it. You are embarrassing yourselves. We already have standards and you need to stop recreating everything in JavaScript.
评论 #14361630 未加载
systematical大约 8 年前
Who uses feeds? Who uses XML?
ehosca大约 8 年前
stopped reading after &quot;JSON is simpler to read and write, and it’s less prone to bugs.&quot; ....
donohoe大约 8 年前
I have grave concerns that this publishing format is delivered to us by two people that, as far as I can see, have limited to zero publishing background.<p>That said, they&#x27;re being responsive to questions in Issues, so I remain optimistic.
评论 #14371282 未加载