2
我有一個jQuery http請求,它以json字符串的形式返回對象。在這裏,我必須做的是將json轉換爲jquery對象,並將值賦給html元素......以下是要轉換的對象的結構。將json字符串轉換爲jquery中的對象
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
}]
}
現在我將如何轉換這個字符串上述對象結構。
什麼是你的問題? JSON有幾乎所需的形式,所以只需解析它。 – Sirko