Skip to content

Instantly share code, notes, and snippets.

@ssisaias
Created December 8, 2017 12:39
Show Gist options
  • Save ssisaias/938bf123f326b1cfec3bf5957ecd8e92 to your computer and use it in GitHub Desktop.
Save ssisaias/938bf123f326b1cfec3bf5957ecd8e92 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var obj = JSON.parse(fs.readFileSync('fileURI', 'utf8'));
total = 0;
// obj is the root element; you can change <items> for whatever array you like
obj.items.forEach(element => {
if(element.snippet.totalReplyCount>0){
element.replies.comments.forEach(reply => {
total++;
})
}
total++;
});
console.log('\n' + total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment