I have a method in my controller class that returns json data and it is in the following format
[
{
"userRoleMappingTO":{
"userRoleMappingId":1,
"applicationId":1,
"userId":194,
"roleId":1,
"smartwcmTreeId":1
},
"roleTO":{
"roleId":1,
"roleName":"Consumer",
"applicationId":1
},
"userTO":{
"userId":194,
"applicationId":"pgm-apn",
"username":"joe.antony",
"password":"password1",
"email":"[email protected]",
"firstName":"Joey",
"lastName":"Anto",
"enabled":true,
"userCreated":"sitepmadm",
"userModified":"sitepmadm",
"createdTime":1423755723104,
"updatedTime":1423755961440
}
},
{
"userRoleMappingTO":{
"userRoleMappingId":2,
"applicationId":1,
"userId":189,
"roleId":2,
"smartwcmTreeId":1
},
"roleTO":{
"roleId":2,
"roleName":"Contributor",
"applicationId":1
},
"userTO":{
"userId":189,
"applicationId":"pgm-apn",
"username":"test.user",
"password":"password1",
"email":"[email protected]",
"firstName":"newuser",
"lastName":"usertest",
"enabled":true,
"userCreated":"sitepmadm",
"userModified":"sitepmadm",
"createdTime":1423490983028,
"updatedTime":1423490983028
}
}
]
I am trying to display this data as a datatable and the only fields I would require are userId,username, roleName applicationId
I normally initialize the datatable as follows
$('#example').dataTable({
"ajax": {
"url": "/the url",
"dataSrc": "",
},
"columns":[
{"data": "userId"},
{"data": "applicationId"},
{"data": "username"},
{"data": "roleName"},
],
});
What changes do I need to make to get the correct data displayed in my table