How can i deal with json like "List"
How can i deal with json like "List"
Swain_Ho
Posts: 2Questions: 1Answers: 0
the json is
{
"recordsFiltered": 8,
"data": [{
"userInfo": {
"name": "admin",
"birthday": "2017-02-15 19:38:43",
"gender": 1
},
"user": {
"id": "ceecc59641a34a659caac7f4f85a9dc8",
"loginname": "superadmin",
"nickname": "sa",
"isOnline": false,
"disabled": false,
"email": "wizzer@qq.com",
"phone": "18888888888",
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}, {
"userInfo": {
"name": "po",
"birthday": "2017-02-17 14:47:10",
"gender": 0
},
"user": {
"id": "123",
"loginname": "12",
"nickname": "jon",
"isOnline": false,
"disabled": false,
"email": "p",
"phone": "13333333333",
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}, {
"userInfo": {
"name": "oi",
"birthday": "2017-02-17 14:35:32",
"gender": 1
},
"user": {
"id": "321",
"loginname": "321",
"nickname": "pop",
"isOnline": false,
"disabled": false,
"phone": "13666666666",
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}, {
"userInfo": {
"name": "pipi",
"birthday": "2017-02-17 17:58:02",
"gender": 0
},
"user": {
"id": "666",
"loginname": "666",
"nickname": "uuu",
"isOnline": false,
"disabled": false,
"phone": "13555555555",
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}, {
"userInfo": {},
"user": {
"id": "222",
"loginname": "222",
"nickname": "oojo",
"isOnline": false,
"disabled": false,
"email": "pipi3",
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}, {
"userInfo": {},
"user": {
"id": "2cb858f5c78f4b3ab58c00851dddd828",
"loginname": "yio",
"nickname": "tom",
"isOnline": false,
"disabled": false,
"email": "pipixia@p.c",
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}, {
"userInfo": {},
"user": {
"id": "333",
"loginname": "333",
"nickname": "piy",
"isOnline": false,
"disabled": false,
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}, {
"userInfo": {},
"user": {
"id": "555",
"loginname": "555",
"nickname": "tr",
"isOnline": false,
"disabled": false,
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false
}
}],
"draw": 0,
"recordsTotal": 0
}
houw can i handle json like List<Map<String,Object>>
(the key is user and userInfo)
PS my English is not good XD
This discussion has been closed.
Answers
The documentation for how to read information from objects is available here.
For example you could use:
data: 'user.loginname'
for a column to display the login name.Allan
I try to use data: 'user.loginname' for a column
but it causes a bug when I attempt to order table by loginname
:the condition which was send to backend is "'user.loginname'rather than loginname
Yes - your server-side processing script, whatever that is, would need to be able to accept data in that form. The simple fact is that there is no parameter called
loginname
at the top level of the data object, which is why you need to use the nested data form to tell DataTables where to get it.Allan