A new syndication standard : JSON Feed

With Atom and RSS being the major syndication formats since more than a decade, there’s not much room for another one. In fact, trying to introduce a new one in 2017 is a real challenge as those XML-based formats are used by billions of websites and known by every web developers.

But maybe that’s the problem : two XML-based formats. Working with both of them is tricky, as there both share the same goal using similar schemas on top of a complex markup language. Look at feed-io’s \Rule namespace, you may see by yourself that sometimes I had some headaches writing this library.

So, in order to offer an easier way to serve feeds, two web veterans (Brent Simmons and Manton Reece) proposed a new standard based on JSON with the following motivations :

We — Manton Reece and Brent Simmons — have noticed that JSON has become the developers’ choice for APIs, and that developers will often go out of their way to avoid XML. JSON is simpler to read and write, and it’s less prone to bugs.

So we developed JSON Feed, a format similar to RSS and Atom but in JSON. It reflects the lessons learned from our years of work reading and publishing feeds.

Here’s the example provided in JSON Feed’s specifications :

{
    "version": "https://jsonfeed.org/version/1",
    "title": "My Example Feed",
    "home_page_url": "https://example.org/",
    "feed_url": "https://example.org/feed.json",
    "items": [
        {
            "id": "2",
            "content_text": "This is a second item.",
            "url": "https://example.org/second-item"
        },
        {
            "id": "1",
            "content_html": "<p>Hello, world!</p>",
            "url": "https://example.org/initial-post"
        }
    ]
}

Really easy to read. So easy I decided to implement this standard in feed-io.

Advertisements

feed-io v2.4 : Json serialisation

In version 2.4, feed-io introduces the ability to convert feeds in valid JSON string :


$feedIo = \FeedIo\Factory::create()->getFeedIo();

$feed = $feedIo->read('http://php.net/feed.atom')->getFeed();

echo json_encode($feed);

The whole feed is exported in the JSON string, including medias, categories and additional elements.