Sorry for the Atom Spam

There's probably two subscribers to my feed, and one of them yelled at me :p But Google Reader should be back to business now, shortly after showing 400+ new items from this website. Atom has an ID that it uses, and Google Reader apparently keeps track of your read items by that ID and doesn't care about the date at all, evidently. So, new items showed up back to the beginning of this website.

So, will there be 400+ new items every time I post? No. It has all those IDs now, which are new and changed, and unless I change them, they won't show up again.

I can't just write a post apologizing though. I have to talk about the new cool thing that I'm working on here at home. I've talked about it before but apparently, wasn't able to carry through with it. Reasons were mainly that my laptop proved to be way to slow after the initial "wow" factor of installing Ubuntu. (My reaction now would be more "Wow, FreeBSD on a ThinkPad RULES!") The thing I'm talking about is my seamless integration between front end Javascript and backend Java. I wrote about it here. But I've made a few changes.

First, instead of the backend generating XML, it'll just read XML and spit out results in JSON. I'm kind of partial to that technology because of the name... it just kicks ass. I got my first foray into JSON last week at work. Initially, our backend PHP was just returning a few things, like 3, for the front end Javascript to parse and spit into HTML on the website. What the final requirements called for was way more complex, and I didn't want to have to come up with some naming scheme, because it would just get so ugly. Some things were related to each other but not to everything. It would be something like this:

"What is my name?:Jason,Steve,Albert:Jason:True: Jason,80%:Steve,5%,Albert:15%,2000,Elite"

This is like a quiz or trivia, where the question was "What is my name?", the possible answers "Jason,Steve,Albert" comma separated, the correct answer "Jason", whether that person got it write "True", and finally the percentages that other people guessed, the total points for that user "2000", and their ranking "Elite". And that's not even all of it. It has to include the next question, and all of those possible answers. Painful. So instead, this is what it looks like:

"LastQuestion" : {
"Text" : "What is my name?",
"User" : {
"Points" : "2000",
"AnswerPercentages" : {
"Jason" : "80",

Much easier to maintain, much easier to read, much MUCH easier for the front end to parse! This can be parsed like this... assume your callback function is called "callback" and is passed whatever is returned from the server, e.g. the JSON code above:

function callback(data){
var obj = eval(data);
alert(obj.LastQuestion.Text); // will alert "What is my name?"

Yup, it's that easy.

Next affair... I'll need, and will build over time, a large Javascript library for building out websites with the data returned from the server. Tables, forms, etc. This will generally be a pain in the ass and is attributed to me delaying this project for as long as possible. Ugh.

If I get tired of that, then something's gotta give, and I'll either stop this crazy experiment or go crazy writing Javascript for hours and hours. Thank God for FireBug.

blog comments powered by Disqus