❤️💙💚 38
Implementing JSON Feed

Dr. Drang, after adding JSON Feed support for both his blog publishing engine and his homegrown feed reader:

JSON Feed, for all its advantages, may be a flash in the pan. Not only do bloggers and publishing platforms have to adopt it, so do the major aggregator/reader services like Feedly and Digg and the analytics services like FeedPress and FeedBurner. But even if JSON Feed doesn’t take off, the time I spent adding it to my blog and aggregator was so short I won’t regret it.

Again I say: easier to generate, easier to parse.

Update: Rob Wells on adding JSON feed to his site:

I think this is what all the people complaining on the Hacker News thread missed. Working in JSON is comfortable and familiar — the tools are good and you get told when something goes wrong. Working with XML can be unclear and a bit of a pain, and creating an invalid document is a risk.

So my super-duper advanced JSON Feed implementation is… constructing a dict, adding things to it and passing it off to the JSON module that I use all the time. Taken care of.

I do something similar to what Wells and Drang do. DF’s RSS and Atom XML feeds are generated via templates: skeleton XML documents with tokens and loop constructs where the actual content gets filled in. But for JSON Feed I just build a Perl data structure that maps exactly to the JSON Feed spec, and just call a single function from the standard JSON module and it gets printed. That’s it. A template would add complexity.

Tuesday, 23 May 2017