title: JSON array string to JSONArray Object in Java
body: <p>I'm new to JSON manipulation in Java and I have a String in the form of a JSON Array with several layers I need to access and put into class attributes. For example, here's my JSON object:</p>
  
  <pre><code>{"JsonObject" : [{"attributeOne":"valueOne",
                    "attributeTwo":"valueTwo",
                    "attributeThree":[{"subAttributeOne":"subValueOne",
                                       "subAttributeTwo":"subValueTwo"}],
                    "attributeFour":[{"subAttributeOne":"subValueThree",
                                      "subAttributeTwo":"subValueFour"}],
                    "attributeFive":"valueThree"},
                   {"attributeOne":"valueFour",
                    "attributeTwo":"valueFive",
                    "attributeThree":[{"subAttributeOne":"subValueFive",
                                       "subAttributeTwo":"subValueSix"}],
                    "attributeFour":[{"subAttributeOne":"subValueSeven",
                                      "subAttributeTwo":"subValueEight"}],
                    "attributeFive":"valueSix"}]}
  </code></pre>
  
  <p>Lets say I have a class called MyClass that has these attributes, how would i parse this string, knowing this is an array of n Objects, each containing "attributeOne, attributeTwo, ..., attributeFive"?</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>public MyClass[] jsonToJava (String jsonObj)
  {
      ArrayList&lt;MyClass&gt; myClassArray = new ArrayList&lt;MyClass&gt;();
  
  
      //Somehow create a JSONArray from my jsonObj String
      JSONArray jsonArr = new JSONArray(jsonObj); //Don't know if this would be correct
  
      for(int i=0; i&lt;jsonArr.length; i++){
          MyClass myClassObject = new MyClass();
          myClassObject.setAttributeOne = jsonArr[i].getString("attributeOne");
          // How can I access the subAttributeOne and Two under attributeThree and Four?
          // add all other values to myClassObject
          myClassArray.add(myClassObject);
      }
      return myClassArray;
  }
  </code></pre>
  
  <p>As you can probably tell, I'm fairly new to programming :P Thanks in advance for the help!</p>