title: org.json.JSONObject cannot be converted to JSONArray in Android Studio
body: <p>I want to retrieve a row in my PHP MySQL and put it in my spinner. I have this of error:</p>
  
  <pre><code>06-13 04:56:53.656 10276-10342/com.example.eugene.spinnersql W/System.err: org.json.JSONException: Value {"result":[{"DriverID":"28","VehicleID":"122","BodyType":"Sedan","Make":"Toyota","Series":"Vios"},{"DriverID":"28","VehicleID":"119","BodyType":"Sedan","Make":"Honda","Series":"Civic"}]} of type org.json.JSONObject cannot be converted to JSONArray
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at org.json.JSON.typeMismatch(JSON.java:111)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at org.json.JSONArray.&lt;init&gt;(JSONArray.java:96)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at org.json.JSONArray.&lt;init&gt;(JSONArray.java:108)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at com.example.eugene.spinnersql.DataParser.parseData(DataParser.java:66)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at com.example.eugene.spinnersql.DataParser.doInBackground(DataParser.java:61)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at com.example.eugene.spinnersql.DataParser.doInBackground(DataParser.java:19)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
  06-13 04:56:53.657 10276-10342/com.example.eugene.spinnersql W/System.err:     at java.lang.Thread.run(Thread.java:818)
  06-13 04:56:53.725 10276-10311/com.example.eugene.spinnersql W/EGL_emulation: eglSurfaceAttrib not implemented
  06-13 04:56:53.725 10276-10311/com.example.eugene.spinnersql W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xdfefe220, error=EGL_SUCCESS
  </code></pre>
  
  <p>Here is my Data Parser.</p>
  
  <pre><code> private int parseData(){
      try {
          JSONArray ja = new JSONArray(jsonData);
          JSONObject jo = null;
  
          vehicles.clear();
          Vehicle s = null;
  
          for(int i = 0; i &lt; ja.length(); i++){
              jo = ja.getJSONObject(i);
  
              int vehicleid = jo.getInt("VehicleID");
              String make = jo.getString("Make");
              String series = jo.getString("Series");
  
              s = new Vehicle();
              s.setVehicleID(vehicleid);
              s.setMake(make);
              s.setSeries(series);
  
              vehicles.add(vehicleid + " " + make + " " + series);
          }
  
          return 1;
  
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Here is my Data Downloader:</p>
  
  <pre><code>private String downloadData(){
      HttpURLConnection con = Connector.connect(urlAddress);
      if(con==null){
          return null;
      }
  
      InputStream inputStream = null;
      try {
          inputStream = new BufferedInputStream(con.getInputStream());
          BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
  
          String line=null;
          StringBuffer response = new StringBuffer();
  
          if(bufferedReader != null){
  
              while((line=bufferedReader.readLine()) != null){
                  response.append(line+"\n");
              }
  
              bufferedReader.close();
  
          } else {
              return null;
          }
  
          return response.toString();
  
      } catch (IOException e) {
          e.printStackTrace();
      } finally {
          if(inputStream != null){
              try{
                  inputStream.close();
              } catch (IOException e){
                  e.printStackTrace();
              }
          }
      }
      return null;
  }
  </code></pre>
  
  <p>This is my Connector: </p>
  
  <pre><code>public static HttpURLConnection connect(String urlAddress){
      try {
          URL url = new URL(urlAddress);
          HttpURLConnection con = (HttpURLConnection) url.openConnection();
  
          con.setRequestMethod("GET");
          con.setConnectTimeout(20000);
          con.setReadTimeout(20000);
          con.setDoInput(true);
  
          return con;
      } catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>Here is my Data Getter and Setter:</p>
  
  <pre><code>public class Vehicle {
  
  int VehicleID;
  String Make, Series;
  
  
  public int getVehicleID() {
      return VehicleID;
  }
  
  public void setVehicleID(int vehicleID) {
      VehicleID = vehicleID;
  }
  
  public String getMake() {
      return Make;
  }
  
  public void setMake(String make) {
      Make = make;
  }
  
  public String getSeries() {
      return Series;
  }
  
  public void setSeries(String series) {
      Series = series;
  }
  
  }
  </code></pre>