title: JSON Parsing Nested Array Objects
body: <p>Using <a href="https://code.google.com/archive/p/json-simple/" rel="nofollow">Simple-JSON</a> on the following JSON formatted file, I'm having a lot of trouble understanding how to access the objects within the array under "name".</p>
  
  <p>JSON File:</p>
  
  <pre><code>[
      {
          "name":{
              "firstName": "Developer",
              "lastName": "D"
          },
          "id": 00, 
          "permissionLevel": 3, 
          "password": 12345
      },
      {
          "name":{
              "firstName": "Bob",
              "lastName": "Smith"
          }, 
          "id": 01, 
          "permissionLevel": 2, 
          "password": 23456
      }
  ]
  </code></pre>
  
  <p>I'm able to obtain the information for all of the other contents because they're not located in a nested array; However, when I attempt to retrieve the objects under "name", all that is output is the String found in the JSON file.</p>
  
  <p>Current code:</p>
  
  <pre><code>String[] searchData = {
                      "name",
                      "firstName",
                      "lastName",
                      "id",
                      "permissionLevel",
                      "password"
                  };
  
  jsonArray = (JSONArray)new JSONParser().parse(s);
  for(int i = 0; i &lt; jsonArray.size(); i++){
      JSONObject jo = (JSONObject)jsonArray.get(i);
      for(int j = 0; j &lt; searchData.length; j++){
          System.out.println(
                  searchData[j] + ": " + jo.get(searchData[j]));
      }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>name: [{"firstName":"Developer","lastName":"D"}]
  firstName: null
  lastName: null
  id: 0
  permissionLevel: 3
  password: 12345
  name: [{"firstName":"Bob","lastName":"Smith"}]
  firstName: null
  lastName: null
  id: 1
  permissionLevel: 2
  password: 23456
  </code></pre>
  
  <p>As you can see, "name" outputs a String from the JSON file, and not each individual value.</p>
  
  <p>In the end, I need to write a universal code that can accept new "searchData" tags for each file that's input.</p>
  
  <ol>
  <li>Might someone be able to direct me how to obtain objects held
  within nested arrays?</li>
  <li>Or perhaps I need to use a different Library? If so, which one is the most efficient for Java? I'm not programming for Android, and I continue to find Library suggestions for Android, constantly. </li>
  </ol>
  
  <p>My apologies if this post is a dupe, but no other posts are aiding me.</p>