-2

I have a json data with count attribute I want to remove "count":2 data from Json data.

Here is the Json data:

{"count":2,"value":[{"StudentId":"5","RollNo":"12228","StudentName":"Farhan","Attandance":"true"},{"StudentId":"6","RollNo":"443433","StudentName":"Arfan","Attandance":"False"}]}

I want to show like this - how is possible using jQuery?

[{"StudentId":"5","RollNo":"12228","StudentName":"Farhan","Attandance":"true"},{"StudentId":"6","RollNo":"443433","StudentName":"Arfan","Attandance":" False"}]

Here is my Ajax call

$(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);
                }
            });
        })


    })
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • `delete your_obj["count"];` – Nick Parsons Nov 02 '18 at 11:14
  • can you plz tell me how dear? – Aliyange553 Nov 02 '18 at 11:15
  • 1
    @Aliyange553 you don't need us to tell you, you can find answers in many places already: https://www.google.co.uk/search?safe=active&rlz=1C1GCEU_enGB821GB821&ei=oDPcW8q3JuydgAbfvajACw&q=javascript+delete+object+property&oq=javascript+delete+object+property&gs_l=psy-ab.3..0i67k1j0i7i30k1j0l7j0i30k1.3128.5191.0.5311.19.14.4.0.0.0.133.1283.10j4.14.0....0...1c.1.64.psy-ab..4.12.910...0i13k1j0i13i30k1.0.04w-3TYlZ28 – ADyson Nov 02 '18 at 11:23

1 Answers1

3

Access that using data.value; where data is the original object:

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);
Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62