arrays - Getting tags and tag count using the tumblr api json feed [jquery] -


i'm having bit of tricky problem tumblr api. getting every tag posts , storing in array. means if array used more once doubles up. want able store tag once , store how many times it's appeared. ideas? thinking object array work struggling working out if tag has been put array , how update "count" value.

var alltags = []; var start = 0; var cleantags = [];  $(function() {   tumblrtag = function(tag,count) {     this.tag = tag;     this.count = count;         }  gettags()  });  function gettags() {      var tumblrapi = 'http://blog.rainbird.me/api/read/json?callback=?&num=50&start=' + start;        $.getjson(tumblrapi, function (data) {          $(data.posts).each(function (i, post) {           $(post.tags).each(function (i, tag) {              if (typeof (tag) === 'string') {              newtag = new tumblrtag(tag, "1");              alltags.push(newtag);               }            });         });         if (start + 50 < data['posts-total']) {           start = start + 50;           gettags();         } else {          console.log("complete");          console.log(alltags);         }       });  } 

http://jsfiddle.net/k2uml/

you this:

obj[tag] = count; 

and when new tags use along lines of

if( obj[newtag] ){   obj[newtag] += 1; }else{   obj[newtag] = 1; } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -