title: How to get values from JSONObject in Java?
body: <p>I am trying to parse a JsonArray and get its values but I am gettign error when I use </p>
  
  <pre><code>   jitem.getString("firstitem"); 
  </code></pre>
  
  <p>or </p>
  
  <pre><code>  jitem.getJSONObject("firstitem");
  </code></pre>
  
  <p>or</p>
  
  <pre><code> jitem.get("firstitem");
  </code></pre>
  
  <p>Following is the code snippet.</p>
  
  <pre><code>  JSONArray arr_items = new JSONArray(str); 
          if(arr_items!=null &amp;&amp; arr_items.size()&gt;0){
  
              for(int i=0;i&lt;arr_items.size();i++){
              JSONObject jitem = arr_items.getJSONObject(i);//works fine till here
               jitem.getString("firstitem"); //throws exception here
              }
  </code></pre>
  
  <p>This is the JSONArray that I am parsing </p>
  
  <pre><code> [{"firstitem":"dgfd","secondtitem":"dfgfdgfdg","thirditem":"fdgfdgdf@sjhasjkdsha.com","fourthitem":"jkksdjklsfjskj"}]
  </code></pre>
  
  <p>what I am doing wrong? How to get these values by using keys?</p>
  
  <p><strong>Update:Note</strong> This array and its parameters are not null at all. They all have valid values. </p>