我有一个具有count属性的json数据,我想从Json数据中删除"count":2
数据。
这是Json数据:
{"count":2,"value":[{"StudentId":"5","RollNo":"12228","StudentName":"Farhan","Attandance":"true"},{"StudentId":"6","RollNo":"443433","StudentName":"Arfan","Attandance":"False"}]}
我想这样显示-使用jQuery怎么可能?
[{"StudentId":"5","RollNo":"12228","StudentName":"Farhan","Attandance":"true"},{"StudentId":"6","RollNo":"443433","StudentName":"Arfan","Attandance":" False"}]
这是我的Ajax电话
$(document).ready(function () {
$('#btnConvert').click(function () {
$('#result').append(JSON.stringify(makeJsonFromTable('MyTable')))
$('#result').show()
var d = JSON.stringify(makeJsonFromTable('MyTable'));
var d2 = d.value;
$.ajax({
url: "@Url.Action("AddUser")",
type: "POST",
data: JSON.stringify(value),
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (response) {
alert(response.responseText);
},
success: function (response) {
alert(response);
}
});
})
})
答案 0 :(得分:3)
使用data.value;
(其中data
是原始对象)进行访问:
var data = {"count":2,"value":[{"StudentId":"5","RollNo":"12228","StudentName":"Farhan","Attandance":"true"},{"StudentId":"6","RollNo":"443433","StudentName":"Arfan","Attandance":"False"}]};
data = data.value;
console.log(data);