Hello everyone,
I have JSON data which has array of objects that has timestamp in EPOCH form. Now, I want the number of times a date is repeated(count of same date repeated) so as to generate a graph.
Please do help me.
var obj = [{
"client_msg_id": "3a223f8d-b5aa-4c9c-9b63-045ec6f90b58",
"type": "message",
"text": "hey there",
"ts": "1567872490.001300",
"source_team": "TN4AF0V5W",
"team": "TN4AF0V5W",
"user_profile": {
"real_name": "marvelmohinish99",
"team": "TN4AF0V5W"
}
},
{
"client_msg_id": "3a223f8d-b5aa-4c9c-9b63-045ec6f90b58",
"type": "message",
"text": "welcome",
"ts": "1567872490.001300",
"source_team": "TN4AF0V5W",
"team": "TN4AF0V5W",
"user_profile": {
"real_name": "marvelmohinish99",
"team": "TN4AF0V5W"
}
},
{
"client_msg_id": "3a223f8d-b5aa-4c9c-9b63-045ec6f90b58",
"type": "message",
"text": "Help me",
"ts": "1567872490.001300",
"source_team": "TN4AF0V5W",
"team": "TN4AF0V5W",
"user_profile": {
"real_name": "marvelmohinish99",
"team": "TN4AF0V5W"
}
}
];
for(var i=0;i<obj.length;i++){
var text = obj[i].text;
var source_team = obj[i].source_team;
var user_profile = obj[i].user_profile;
var real_name = user_profile.real_name;
var ts = obj[i].ts;
console.log(text);
console.log(source_team);
console.log(user_profile);
console.log(real_name);
console.log(ts);
}
obj.forEach(function(x, i) {
setTimeout(function() {
var utc = x.ts;
var d= new Date(0);
d.setUTCSeconds(utc);
var entry = "<div class='name'>" + x.user_profile.real_name + "</div><div class='text'>" + x.text+"</div><div class='ts'>"+ d+"</div>";
document.getElementById("output").innerHTML += entry;
}, 2 * i);
});