下面是我的json结构,我需要在datatable中的列中检索ContactRole.staffRoleDescription数据。
我尝试过一些像"mdata" :"ContactRole.staffRoleDescription"
这样的方法。但我没有得到输出。如果不能通过普通的数据表语法来完成,那么如何通过迭代来实现
{
"favoriteStatus": true,
"favoriteId": 1,
"name": "Jason Parker",
"phoneNumber": "+1 987-654-3210",
"businessRole": "Account Executive",
"ContactRole": [
{
"id": "1",
"roleStatus": "internal",
"staffRoleDescription": "MSC"
},
{
"id": "2",
"roleStatus": "external",
"staffRoleDescription": "AP (Apple Professional)"
}
],
"email": "email@domain.com"
}
答案 0 :(得分:0)
以下代码正在运行:
table = {
"favoriteStatus": true,
"favoriteId": 1,
"name": "Jason Parker",
"phoneNumber": "+1 987-654-3210",
"businessRole": "Account Executive",
"ContactRole": [
{
"id": "1",
"roleStatus": "internal",
"staffRoleDescription": "MSC"
},
{
"id": "2",
"roleStatus": "external",
"staffRoleDescription": "AP (Apple Professional)"
}
],
"email": "email@domain.com"
}
for (i = 0; i < 2; i++) {
alert(table["ContactRole"][i]["staffRoleDescription"])
}