How to display generic json event to show data instead of [Object object]
How to display generic json event to show data instead of [Object object]
chencho
Posts: 1Questions: 1Answers: 0
Hello,
I have a device that sends a json with different events in this way
[ {"timestamp": 12387414, "event": {"foo": "data1"} }]
[ {"timestamp": 12387414, "event": {"bar": "data2"} }]
and this datatable initialization
infoTable = $('#infoTable').DataTable({
data: infoData, /*function() {
return JSON.stringify(infoData[0].timestamp);
},*/
"paging": false,
"scrollY": "400px",
scrollCollapse: true,
"language": {
"emptyTable": "No data available in table",
"infoEmpty": "No entries to show"
},
columnsDefs: [
{ "width": "20%", "targets": 0 },
],
aoColumns: [
{ data: 'timestamp' },
//{ data: 'event'}
{ mData: 'event',
mRender: WHAT HERE?
}
]
});
What should I do instead of WHAT HERE? ?
Thank you
This discussion has been closed.
Answers
Because you don't know what the property names of the
event
object are you would need to use$.each()
orfor ... in ...
to loop over the properties and their values.Based on the above, what do you want the output to be?
Allan