[wp-hackers] JSON Syndication

Matt Patenaude MattPat at mattpat.net
Sat Feb 17 15:28:17 GMT 2007


Thanks for the responses guys! Couple of points I'd like to bring up.

> In effort to not just be a talking head:
>   - http://jrm.cc/wp-json.php
>   - http://jrm.cc/wp-json.phps
>
> And it even passes a basic "validaton":
>   - http://jrm.cc/extras/json-valid.html

Awesome stuff, man! This was just what I was looking at.

> The biggest gotchas:
>   - Content-Type, which to use?
>   - Escaping, making sure it's "right"

Well, as for content-type, application/json is the MIME-type  
specified by the JSON spec, but I'd imagine our own feed format would  
take its own content-type (for example, Atom is application/atom+xml,  
not just application/xml)... maybe application/feed+json, or  
something similar? It would all depend on how mature the  
specification became.

As for escaping, I handle it on my website by using a JSON library:  
http://tuxcms.cvs.sourceforge.net/tuxcms/tuxcms/json.php?view=markup

Note how, in the above file, my entire feed is constructed using PHP  
data structures, and then one line converts it into the JSON feed.  
Cool, huh? :)

> It's a neat idea, but I have two problems with it:
>
> 1. It's too late. There's already a format war between Atom and RSS,
> not to mention podcasting enclosures, GeoRSS, and everything else.

True, but in my opinion, they both have the fundamental problem of  
using complex XML. I'm not saying by any means to replace XML feeds  
by JSON feeds, but JSON feeds are definitely the new movement.  
Del.icio.us and Yahoo! have both started offering their web service  
outputs in JSON in addition to XML, because it's so simple to use  
with almost any programming language (which is largely the goal of  
any syndicated content). Every movement has to start somewhere, and  
in computers, I don't think there such a thing as too late. (OK, yes  
there is, but I don't think this is an instant of it :P).

> 2. The #1 thing that makes JSON cool and useful is the &callback=x
> parameter, which allows it to be called cross-domain using dynamic
> script tags.

Well, callbacks might be cool, but I don't think they're the #1 thing  
that makes JSON cool-- I'd say it's the fact that it's simple,  
lightweight, and supported almost everywhere.

FIrst of all, callbacks wouldn't have to necessarily be implemented  
by WordPress. In fact, I don't even think there is much use for a  
feed specification. If the format caught on, it would probably be  
included using a link element, not a script element. Besides, the  
inclusion would be done by a plug-in, so we would control how it was  
included on the page. The plug-in would allow for the syndication of  
JSON, not necessarily its use on a web page.

Also, note the above implementation's (by Jeff Minard) use of  
callback (pass a random callback to the first URL). No matter what  
you pass, it wraps the feed in wp_jason_feed(eval()). This would  
provide a little extra control for feeds used on other WordPress sites.

Anyway, you both said the best way to go is to make a plug-in, and I  
think I'll do just that. Thanks for the help!

-Matt

On Feb 16, 2007, at 11:51 AM, Mike Purvis wrote:

> It's a neat idea, but I have two problems with it:
>
> 1. It's too late. There's already a format war between Atom and RSS,
> not to mention podcasting enclosures, GeoRSS, and everything else.
>
> 2. The #1 thing that makes JSON cool and useful is the &callback=x
> parameter, which allows it to be called cross-domain using dynamic
> script tags. As an example, see how Google's geocoder works:
>
> http://maps.google.com/maps/geo?output=json&callback=dostuff
>
> However, it be disasterously irresponsible to implement something like
> this in Wordpress and encourage people to use it. It's an open
> invitation to run arbitrary JavaScript on random domains, a weakness
> that XML simply does not have.
>
> At any rate, the first step in this process would be to develop the
> feed as a plugin, and demonstrate that it offers something not
> available in existing syndication schemes. If this were truly the
> case, then perhaps the leet hax0rs would consider adding it to the
> core, down the road.
>
> Mike
>
>
> On 2/15/07, Matt Patenaude <MattPat at mattpat.net> wrote:
>> Hey there,
>>
>> For more than a year now, I've been developing my own content
>> management system called Tux CMS (http://blogwithtux.org), which
>> takes a lot of its feature ideas and concepts from WordPress (I've
>> also ported a few WP themes over to it). Extremely little borrowed
>> code, but a lot of borrowed inspiration, so first of all, I'd like to
>> say thanks to the WordPress team for an awesome product! :)
>>
>> Second, though, I would like to suggest a feature. For the past few
>> months I've been getting fed up with XML, and getting to know JSON.
>> XML can be quite clunky, and really isn't suited for syndication when
>> you think about it. JSON, on the other hand, is a very lightweight
>> data serialization language, which greatly improves size and
>> simplicity of use of syndicated content (it has direct relationships
>> to programming structures, so it's easier to access programmatically
>> than XML through the DOM).
>>
>> I'm trying to get a movement going of a syndication format made
>> completely in JSON. The first step, I figured, was to develop an
>> informal specification: http://howto.blogwithtux.org/index.php?
>> title=JSON_feed.
>>
>> The next step was to create a working implementation of my
>> specification: http://www.mattpat.net/json.php. But then, when trying
>> to decide on the third step, I wondered, hmm, what would get this the
>> most exposure? Why, implementation by one of the best and most widely
>> used blogging engines, of course! I'm a big fan of WordPress (despite
>> the fact that I write my own CMS... of course, it's open source, so I
>> would call it more friendly competition), so I thought I might start
>> here.
>>
>> Is this something WordPress developers might be interested in? I want
>> to make this a large movement... I even wrote an article on A List
>> Apart for it (still waiting for a response on it).
>>
>> Let me know!
>>
>> Sincerely,
>> Matt Patenaude
>> http://www.mattpat.net
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
> -- 
> http://uwmike.com // http://googlemapsbook.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list