title: Creation of a multi-level JSON string
body: <p>I want to create a multi-level JSON string with JS.</p>
  
  <p>Scenario</p>
  
  <p>3 countries with 5 grandfathers with 3 kids which whom also have 3 kids that have 5 friends.</p>
  
  <p>I get the data from a external JSON file that looks like this. </p>
  
  <pre><code> {"countries":[
      {
          "name":"USA",
  
          "grandfathers":[
              {
                  "gFName":"Steve",
                  "grandfathersKid":[
                      {
                          "gFKName": "Linda",
                          "kid": [{
                              "name": "Steve JR", 
                              "friends": [{
                                  "name": "Kriss|John|Martin|Steven"
                              }]
                          }
                          ]
                      }
  
                  ]
              }
          ]
      }
  ]}
  </code></pre>
  
  <p>And now I want to store some of the countries with people and their relatives and friends in a a new JSON list that looks exactly as the list made in the external json file. I aim to use this "homemade" list later on in the script.</p>
  
  <p>My initial response for this was</p>
  
  <pre><code>var tree = new Array();
  
  tree = {};
  
  
  var countries = new Array();
  
  countries[0] = "canada";
  countries[1] = "USA";
  countries[2] = "Mexico";
  countries[0][0] = "Steve"; //Lives in Canada
  countries[0][0][0] = "Linda"; //Daughter of Steve
  countries[0][0][0][0] = "Steve JR"; // Kid of Linda
  countries[0][0][0][0][0] = "Kriss"; //Steves Friend
  ...
  
  
  $.each(countries...function(index, value){
        tree[index].country = value;
  
    $.each(grandfathers...function(key, value){
        tree[index].country[key].grandfather = value;
  
  }
  </code></pre>
  
  <p>And so on, but this is not giving me the result I want. What am I doing wrong? And a more effective way than to take each of everything?</p>
  
  <p>Third edit...</p>