adding array (list of values) to a json object

bialspeatuipt

New Member
I try to loop through some json (clustered twees from twitter) and count how often particular keywords (hashtags) are present so I can create an ordered list of frequent words.
this (19)
that (9)
hat (3)
this I've done by creating \[code\]var hashtags = []; \[/code\]first time I add a new word i add th word and give the value 1\[code\]hashtags[new_tag] = 1;\[/code\]the next time a find the same worj I just add to the number\[code\]hashtags[hashtag]+=1;\[/code\]the result is a simple structure with words and values. I can list out what I need with\[code\]$.each(hashtags, function(i, val){ console.log(i+ " - "+ val);})\[/code\]Now I realize I also nee to know what clusters these words where found in. So; I thing I need to add a list (array) to my "hashtags".I guess what I try to create is a json structure like this:\[code\]hashtags: {"this": 19, clusters: [1,3,8]},{"that": 9, clusters: [1,2]}\[/code\]How do I add the arrays to the hashtags object?
 
Top