feed-io 3 : JSON Feed support

In my previous post I introduced JSON Feed, a new syndication standard published on May 17, 2017.

And now feed-io supports this new format since the last release. It was tagged 3.0 as it breaks compatibility with the previous version, which was a necessary evil because FeedIo::format() returned a DomDocument, no longer relevant. Now this method returns a string you can display without calling saveXML() anymore. This is the main change from 2.x to 3.0 and if you need to know everything on how to upgrade your code, please refer to the upgrade guide.

For those how don’t know feed-io yet, it is a PHP library built to read and write feeds initially written with RSS and Atom formats in mind. I sometimes had the feeling that one day a JSON standard will come this way, but I always ended thinking “nay, not that year”. Good news : I’m finally wrong ! And I guess nobody cares about what I am thinking, so now I’ll get to the point : the code.

Continue reading

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.