我有一个 jQuery http 请求,它以 JSON 字符串的形式返回一个对象。这里我要做的是将JSON转换为jQuery对象并将值分配给html元素......以下是要转换的对象的结构:
var Userrights = {
Id: // an id element
ScreenRights: // this is a list with following elements
{
ScreenName:
Create:
Read:
Update:
Delete:
Approve:
Access:
Print:
Email:
};
};
现在,当我收到如下 JSON 字符串时:
{
"Id": "Manager",
"ScreenRights": [{
"ScreenName": "CustomerScreen",
"Create": true,
"Read": false,
"Update": true,
"Delete": false,
"Approve": true,
"Access": true,
"Print": true,
"Email": true
},
{
"ScreenName": "TraderScreen",
"Create": true,
"Read": false,
"Update": true,
"Delete": false,
"Approve": true,
"Access": true,
"Print": true,
"Email": true
},
{
"ScreenName": "DistributorScreen",
"Create": true,
"Read": false,
"Update": true,
"Delete": false,
"Approve": true,
"Access": true,
"Print": true,
"Email": true
}]
}
现在我将如何将此字符串转换为上述对象结构?