loop through simple json object -
how loop through json object each item value? know easy need undestand why there 2 brackets ([]) in first , end of json object.
[// i'm talking [ { "id": 2, "title": "xxxxxxxxx", "author": "mike123", "postdate": "march 12, 2013 @ 6:46 pm", "postdatecreation": "2013-03-12", "posteditdate": null, "postcontent": "eeeeee", "userid": 34 } ] ]// ,
if remove them json still remain valid.
you can loop through json object using $.each loop. here fiddle:
here results array of array of object. i've passed object accessing index results[0] give array results[0][0] give object
code below:
var results=[ [ { "id": 2, "title": "xxxxxxxxx", "author": "mike123", "postdate": "march 12, 2013 @ 6:46 pm", "postdatecreation": "2013-03-12", "posteditdate": null, "postcontent": "eeeeee", "userid": 34 } ] ] $.each(results[0][0],function(key, value){ alert(value); });
$.each can used loop through array or objects follow below link more information:
http://api.jquery.com/jquery.each/
hope helps. please correct me if i'm wrong.
Comments
Post a Comment