Oy oy, it is interesting!

Home

New JSON feed of my blog

Nov222007

Some javascript messing about

Oh that'll come in handy for all those mashups based around me you've been planning... Not a straight feed of what I post every day, it searches the content of the site, probably seven or eight years worth of postings now.

JSON is "javascript object notation" btw (if you have no interest in javascript best stop reading now), presenting information in such a format you can slot it straight into a script without any more processing needed. XML is great for passing info around the web, except that AJAX requests specifically block you from fetching XML from another website, but you can call javascript from anywhere happily.

It works in the same way as the xml feeds, construct your call to my JSON API (ooh, get me) like this:

http://www.clarkeology.com/javascript/your_callback_goes_here/squirrel+and+magpie.js

And that'll return something like:

callback_goes_here( [{guid:10701,
link:"http://www.clarkeology.com/m/10701/10701/New+JSON+feed+of+my+blog",
title:"New JSON feed of my blog",
description:"Oh that'll come in handy for all those mashups based around me you've been planning... Not a straigh",
category:["javascript",
"json",
"feed",
"xml"],
geo:{lat:51.0800,
lon:1.1645}},
{guid:10278,
link:"http://www.clarkeology.com/m/10278/10278/Mods+and+rockers+all+over+again",
title:"Mods and rockers all over again",
description:"Yesterday I saw a turf war in Folkestone, a ferocious battle between six magpies and three squirrels",
geo:{lat:51.0800,
lon:1.1645}},
{guid:63,
link:"http://www.clarkeology.com/m/63/63/arcade+games",
title:"arcade games",
description:"Walked the long way round Listria Park on the way to Church Street today, and saw two magpies and a",
geo:{lat:51.0800,
lon:1.1645}}] )


Hmm, will reformat that later so it looks nicer here (don't know where all those backslashes came from, they're not there in the real json), and also I should investigate if there is an rss style standard for json blog feed, it's all very well me saying "my blog titles are called mSubject" but if no-one else is using that it's not really going to catch on for blogs... If you don't know what that is, then just come back later, I'm sure to post something about squirrels again soon.

To use these feeds of mine, you want to put some javascript on your page that grabs that feed and does something with it. If you're using the newer version of jquery.com say, you can whack some of my content into your page like this:



// hmm, bah just realised I've done something fundamentally unhelpful, I really do need to have "callback=" in my standard js url to fit in with other people's requirements...

$.getJSON("http://www.clarkeology.com/javascript/callback_goes_here/search.js jsoncallback=?",
function( js ){
for ( var i in js ) {
$('body').append( '<' + 'h2>' + js[i].title + '<' + '/a><' + '/h2><' + 'p>' + js[i].description + '<' + '/p>' ); }
});



I'm doing that on
yourfolkestone.com/javascript

Will be extending this to cover other content soon, ie a list of pubs local to a particular postcode or something like that, won't that be nice?

:: Comment / reply

Paul Clarke's blog - I live and work in Hythe near Folkestone, Kent. Married to Clare and father to Harry and Tommy, I am a web dev, and I do js, node, php, and ruby. I like Folkestone Gerald, pubs, restaurants, home automation, history, genealogy, TV, popbitch, squirrels, pirates ☠, time travel, stained glass...

Also from the same week

Some more blog posts from the same week as .

RE: Yes, moved here (to Folkestone) full time back in April [Tuesday 20 November 2007]

RE: Bank Holiday [Tuesday 20 November 2007]

Might be too late, thanks for the offer of help with Coolinge Road though [Tuesday 20 November 2007]

Nothing happens now, that's my bet [Tuesday 20 November 2007]

Most comments on a youtube video EVER! [Wednesday 21 November 2007]

York (being the fourth part of my holiday) [Wednesday 21 November 2007]

New JSON feed of my blog Some javascript messing about [Thursday 22 November 2007]

Captain Jack [Friday 23 November 2007]

Fake GAP voucher [Saturday 24 November 2007]

RE: Fake GAP voucher [Sunday 25 November 2007]

Stoke Newington by the sea [Sunday 23 May 2004]

RE: Stoke Newington by the sea [Thursday 28 April 2005]

Haha, cheers Jacob [Thursday 28 April 2005]

Decent places to get a coffee [Sunday 21 August 2005]

Yes, moved here (to Folkestone) full time back in April [Sunday 21 August 2005]

RE: Yes, moved here (to Folkestone) full time back in April [Tuesday 18 September 2007]

I don't really know Coolinge Road [Thursday 20 September 2007]

Bank Holiday [Tuesday 13 November 2007]

RE: Bank Holiday [Tuesday 13 November 2007]

They have accepted the petition on pm.gov.uk [Tuesday 13 November 2007]

RE: They have accepted the petition on pm.gov.uk [Tuesday 13 November 2007]

These are 'official' petitions [Tuesday 13 November 2007]

RE: These are 'official' petitions [Wednesday 14 November 2007]

She's off work all this week [Monday 26 November 2007]

RE: New JSON feed of my blog [Monday 26 November 2007]

oy oy, it is interesting! [Tuesday 27 November 2007]