1

I found this awesome tip here at how to serialize a .Net DataTable into a Json String using Json.Net with the following code:

  return JsonConvert.SerializeObject(dtProdEv, Formatting.Indented);

I get the following result back:

[
  {
    "Col1": 2,
    "Col2": "\/Date(1292724000000-0200)\/",
    "Col3": 0,
    "Col4": 1,
    "Col5": "\/Date(1292772960760-0200)\/",
    "Col6": null,
    "Col7": null,
    "Col8": 0.0000,
    "Col9": 0,
    "Col10": 1
  },
  {
    "Col1": 2,
    "Col2": "\/Date(1292724000000-0200)\/",
    "Col3": 0,
    "Col4": 2,
    "Col5": "\/Date(1292773781763-0200)\/",
    "Col6": 3,
    "Col7": 1,
    "Col8": 0.0000,
    "Col9": 0,
    "Col10": 2
  }
]

My question is how can I iterate through this result using JQuery? I parse it into an Object using parseJSON, but then I'm stumped. Tks

1 Answer 1

2

You can use $.each to iterate through the whole array.

See the live demo here.

// loop through the array of objects.
$.each(data ,function(i,item){

    // document.write(item["Col7"]); // print specific property


    // loop through the properties of each object.
    $.each(item, function(j, child){

        document.write(child); // print all the childs

    });

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.