I have a jQuery http request which returns me an object in the form of JSON string. Here what I have to do is convert the JSON to the jQuery object and assign the values to html elements… the following is the structure of the object to be converted:
var Userrights = {
Id: // an id element
ScreenRights: // this is a list with following elements
{
ScreenName:
Create:
Read:
Update:
Delete:
Approve:
Access:
Print:
Email:
};
};
Now when I receive a JSON String like the following:
{
"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
}]
}
Now how will I convert this String to above mentioned object Structure?
Jquery:
With that said, if you are using jQuery’s .ajax you could just set
dataType:'json'