Singpolyma

Technical Blog

feed2json

Posted on

I have been doing some work recently with the Outline Converter, upgrading its code and adding more input and output formats. One of the benefits of this is that it can now act as a feed2json converter. Since it is hosted on Ning it doesn’t suffer from the bandwidth restrictions so many other feed2json scripts do. To use it as a feed2json use the following URL format:

http://xoxotools.ning.com/outlineconvert.php?output=json&classes=items&url=FEED URL&callback=CALLBACK

I have already upgraded my version of FreshTags to use this instead of the other feed2json script so that I no longer have to worry about the bandwidth restrictions. Here is the code for the function I am using to convert the JSON data to the Delicious.posts format:

function feedjson2deljson(json_data) {
var rtrn = [];
for(var i=0; i<json_data.items.length; i++) {
obj = {};
obj.d = json_data.items[i].title;
obj.u = json_data.items[i].link;
obj.n = ”;
if(json_data.items[i].description)
obj.n = json_data.items[i].description;
if(json_data.items[i].content)
obj.n = json_data.items[i].content;
rtrn.push(obj);
}//end for
return rtrn;
}//end feedjson2deljson

One Response

Leave a Response