Click here to Skip to main content
15,887,906 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
HI,

i push the object array into an array. then i push that array into another array as below.

C#
var arrayName = focusId;//foucusId is a global variable. it's value will change

     arrayName = new Array();

     for (i = 0; i < _Error_Text.length; i++) {

         var EntityTrackChange = {};
         EntityTrackChange["sErrorText"] = _Error_Text[i];
         EntityTrackChange["iErrorId"] = document.getElementById(_drpErrorType[i]).options[document.getElementById(_drpErrorType[i]).selectedIndex].value;
         EntityTrackChange["sErrorName"] = document.getElementById(_drpErrorType[i]).options[document.getElementById(_drpErrorType[i]).selectedIndex].text;
         EntityTrackChange["sComment"] = document.getElementById("txtErrorComment_" + i).value;
         arrayName.push(EntityTrackChange);

     }

     options.push(arrayName);// options is a global array


i write above code to create an array as below

example:-

focusId :- the id of fouced textarea.then
C#
each focusId have an object array



my doubt is how to access each object array values inside an array?

the array :-
JavaScript
var arr = [[obj1, obj2, obj3], [obj1, obj2]]



thanks.
Posted

1 solution

Try like below (this is an example):

C#
var json = {"forum":[{"id":"1","created":"2010-03-19 ","updated":"2010-03-19 ","user_id":"1","vanity":"gamers","displayname":"gamers","private":"0","description":"All things gaming","count_followers":"62","count_members":"0","count_messages":"5","count_badges":"0","top_badges":"","category_id":"5","logo":"gamers.jpeg","theme_id":"1"}]};

var forum = json.forum;

for (var i = 0; i < forum.length; i++) {
    var object = forum[i];
    for (property in object) {
        var value = object[property];
        alert(property + "=" + value); // This alerts "id=1", "created=2010-03-19", etc..
    }
}


Jquery way

PHP
$.each(json.forum, function(i, object) {
    $.each(object, function(property, value) {
        alert(property + "=" + value);
    });
});




Check below mentioned link for more info : jquery parse json multidimensional array

Another useful one :help with jagged arrays
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900