JSON Nested tables with different keys
JSON Nested tables with different keys

Hi,
Can anyone advise on the following? I have a nested JSON object which I need to use the values of to create a table. The JSON example I have is as follows:
"id7": {
"userInitials": "AB",
"company": "company1",
"orderAmount": "10.00",
"dateCreated": "2019-03-21 09:59:33"
},
"id8": {
"userInitials": "CD",
"company": "company2",
"orderAmount": "20.00",
"dateCreated": "2019-03-21 10:00:09"
},
I know that I can get to the nested data by using id7.userInitials or id8.userInitials, however, I want to be able to just go into the nested data without specifying the id, for example *.userInitials. Is there any way to do this?
Many thanks,
Carl.
Answers
Datatables expects an array of objects with each object being a row in the table. It does not support using your data structure. More info regarding data structures is here:
https://datatables.net/manual/data/#Data-source-types
if you can't change how the server structures the data you could use
ajax.dataSrc
as a function to manipulate the JSON response to match something Datatables supports. This might impact performance depending on data size.Kevin