Skip to content

Instantly share code, notes, and snippets.

@abhididdigi
Created August 4, 2013 17:10
Show Gist options
  • Save abhididdigi/6151039 to your computer and use it in GitHub Desktop.
Save abhididdigi/6151039 to your computer and use it in GitHub Desktop.
Process the output.JSON with node.js.
var _ = require('underscore')._;
fs = require('fs')
fs.readFile('Output.json', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var data = JSON.parse(data);
var filteredJSON = _.uniq(data,false,function(d){return d.name})
var tags = {};
for(var i in filteredJSON){
var tagInEach = filteredJSON[i].tags;
for(var j in tagInEach){
var _tag = tagInEach[j]
if(_.has(tags,_tag)){
tags[_tag]+= 1;
}
else tags[_tag] = 1;
}
}
var arr = [];
for (var i in tags){
var o = {};
o['label'] = i;
o['value'] = tags[i]
arr.push(o);
}
console.log(arr);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment