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]

chenchochencho 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

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Because you don't know what the property names of the event object are you would need to use $.each() or for ... in ... to loop over the properties and their values.

    Based on the above, what do you want the output to be?

    Allan

This discussion has been closed.