How can I count the number of non-empty dailyemails
in the following json?
{
"templates":[
{
"id":"2c1d99d9b6b2fb417601d24c10c9b041a7d6f37b",
"dailyemails":[
"saaa@aa.com",
"aaa.aaa@gmail.com"
],
"name":"Registration Report"
},
{
"id":"45s4dsf4qdgze5zef1z3e2f1zevcd5s6sdfsdfsdf",
"dailyemails":[
],
"name":"Presentation"
},
{
"id":"7d7cc642ca13cc4a998cad364dfe8e623fd95ae3",
"dailyemails":[
"saaa@ss.com"
],
"name":"Live Report"
}
]
}
I am currently reading the total number of nodes Object.keys(myArr).length
:
function metaInfo (id, cb){
var URL = someURLhere
var count = []
fs.readFile(__dirname +'/' + URL+'/myFile.json', 'utf8', function (err, data) {
if (err) cb (err);
obj = JSON.parse(data);
var myArr = obj.nodes;
count.push(Object.keys(myArr).length);
cb(null, count)
});
};
How can I read the number of non-empty dailyemails
?