title: The type of the expression must be an array type but it resolved to JSONArray
body: <p>I am getting an JSON object then converting it into array and trying to access the properties or values, but getting error as <code>The type of the expression must be an array type but it resolved to JSONArray</code></p>
  
  <p>I have to save the JSON data into my Database thats why I am getting all to values in array</p>
  
  <p><strong>My code</strong></p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
  
      Scanner scanner = new Scanner(request.getInputStream());
      String imageData = scanner.nextLine();
      System.out.println(imageData);
      JSONObject jsonObj = new JSONObject(imageData);
      JSONArray jsonArray = jsonObj.getJSONArray("ImageData");
  
      JSONObject innerObj = new JSONObject(jsonArray[0]); // this one is throwing error 
      // eror is `The type of the expression must be an array type but it resolved to JSONArray`
      String counter = innerObj.getString("Counter");
      String name = innerObj.getString("Name");
      String isActive = innerObj.getString("IsActive");     
      System.out.println(counter);
  
  }
  
  System.out.println(imageData); it prints --&gt;
  </code></pre>
  
  <p><code>{"ImageData":[{"Counter":"Counter A","Name":"CountA1.jpg","IsActive":"Y"},{"Counter":"Counter A","Name":"CountA2.jpg","IsActive":"Y"}]}</code></p>
  
  <p>System.out.println(jsonArray); This one prints --></p>
  
  <p><code>[{"Counter":"Counter A","IsActive":"Y","Name":"CountA1.jpg"},{"Counter":"Counter A","IsActive":"Y","Name":"CountA2.jpg"}]</code></p>
  
  <p>I have commented the line in my code where I am getting error</p>