Created
August 4, 2013 17:10
-
-
Save abhididdigi/6151039 to your computer and use it in GitHub Desktop.
Process the output.JSON with node.js.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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