I'm new working with JSON and the getJSON function etc and I'm trying to get data from a JSON that goes down several levels and can have multiple children. At the minute I can see the values I want by using .each with another .each such as:
$.each(data, function(i, value1) {
    $.each(value1, function(i, value2) {
        $.each(value2, function(i, value3) {
            $.each(value3, function(i, value4) {
                $.each(value4, function(i, value5) {
                    $.each(value5, function(i, value6) {
                        alert ("we got "+i);
                    });
The only problem is, I won't always know what is in the JSON and it could have unlimited children. So how would I go about making it dynamic as such?
Basically what I'm looking for is something to keep checking for children until it gets to the lowest level.
Also, I know the value i at the very end is the index for whatever value is in the JSON,
Is there any way to automate this also so that I could check for say, 'name' in the JSON and it would return the value of 'name'?
Here is a sample of the JSON i'm trying to work with:
[
 {
   "children": [
    {
      "children": [
       {
        "children": [
          {
            "children": [
              {
                "bucketPath": "AUDIO\\audio0.mp3",
                "id": 305,
                "modified": "2012-08-02T10:06:52",
                "name": "audio0.mp3",
                "state": "closed"
              }
 
     
     
    