我需要从ajax中的以下Json响应中获取@ odata.context属性的值:
{
"@odata.context":"https://site.sharepoint.com/_api/",
"@odata.type":"#oneDrive.permission",
"@odata.id":"https",
"link":{"scope":"anonymous"}
}
我想在代码中做类似的事情:
$.ajax({
type: "POST",
beforeSend: function (request) {
request.setRequestHeader("Authorization", 'Bearer ' + bearerToken);
},
url: serverUrl,
data: JSON.stringify(params),
dataType: 'json',
contentType: " application/json",
success: function (data) {
var myvalue= data.@odata.context; // ****???
var jsonObject = JSON.parse(data); //this line throws an error Unexpected token o in JSON at position 1
}
});
答案 0 :(得分:0)