I'm putting together some JavaScript that'll be pulling in multiple JSON files whose data will be used in graphs. Ultimately, I need to identify when I've reached the absolute end of an associative array being processed in an $.each() loop (jQuery is involved) in order to trigger the next JSON file. I've bumped into various solutions for a one-tiered object...but what about a MULTI-TIERED object? How does the last row in the last column know it's the LAST?
Here's an example JSON I'm working with:
{
    "Network":{
        "Hardware":262464,
        "Software":53016,
        "Internal Personnel":440202,
        "External Personnel":188658,
        "Outside Services":1344100,
        "Facilities and Overhead":16172,
        "Other":92588,
        "Total":2397200
    },
    "Wide Area Network":{
        "Hardware":75600,
        "Software":18900,
        "Internal Personnel":132300,
        "External Personnel":56700,
        "Outside Services":315000,
        "Facilities and Overhead":6300,
        "Other":25200,
        "Total":630000
    }
}
Here's a rough idea of a loop I'm running on that JSON
function buildColumns(array, parent) {
    $.each(array, function(key, value) {
        var newParent = $('<column>'); 
        $('<columnBox>').append($('<h2>').html(key)).append(newParent).appendTo(parent);
        if(value instanceof Object) buildColumns(value, newParent);     
    });
}
The loop is pseudo-recursive, as you can see, and may not ultimately be what I use. But there you go.
 
     
     
     
    