No Argonauts for this JSON

Reached a point where the number of posts on my twitter photo blog was becoming hard to manage, I decided I needed to figure out a way to organize my work efficiently. Having almost 800 photos in my flickr stream meant that creating a database manually by copying names was going to be time consuming. Knowing that Flickr and programmers had surely taken care of this obstacle, I decided to investigate the flickr API and found a list of photos by photoset method.

Using the data generated by this method was a challenge at first. I initially tried to use the XML output but struggled to create a usable list. I then decided to use the JSON output, which until this project I was unfamiliar with. After creating the list I recognized the object and array structure (see below, some values redacted) including the title variable that I wanted.

var ChicagoList =
{
“photo”: [
{ “id”: “7827394778”, “secret”: “——“, “server”: “7249”, “farm”: 8, “title”: “Hilliard Towers”, “isprimary”: 1 },
{ “id”: “7827395476”, “secret”: “——“, “server”: “7107”, “farm”: 8, “title”: “Hilliard Towers 2”, “isprimary”: 0 },
{ “id”: “7898311488”, “secret”: “——“, “server”: “8448”, “farm”: 9, “title”: “Diversey Brown Line”, “isprimary”: 0 },

…..

{ “id”: “7827407022”, “secret”: “——“, “server”: “8296”, “farm”: 9, “title”: “Typical concrete condo Chicago”, “isprimary”: 0 }
]
};

Using one of my old console.log loops for examining data, I created a short program using bracket notation to access each object (photo) in the list array in sequence and its name variable. I then logged the names to the console and copied the list into a spreadsheet.

for (var i = 0 ; i < 170; i ++) { console.log(ChicagoList.photo[i].title); }

This was a quick and dirty method though, but it did the job. I used the “for loop” which ran for longer than the dataset to ensure I didn’t lose anything. A “while” loop would have been cleaner and I had used file analysis loops like that in AutoLISP. Now that I am concluding Javascript review my next step is to move onto jQuery and AJAX so that I can generate my photo lists server side on my website. I could then provide galleries covering each of my cities on single pages so that people could easily browse my collection from my own website, since I am limited to 30 photos per page as per the conditions of using my non-commercial flickr API key. Wish me luck.