title: JSON error: java.lang.String cannot be converted to JSONObject
body: <p>I'm developing an android app and I'm trying to use <strong><em>Volley Library</em></strong>. The problem that I can't solve is about the JSON. I checked my php file, the result and the Java code but I'm still getting the same error. </p>
  
  <p>The interesting part is that <strong><em>VolleyLog</em></strong> doesn't show an error message but, <strong><em>Log</em></strong>, does. </p>
  
  <pre><code>E/Volley﹕ [1] 2.onErrorResponse: VOLLEY_ERROR
  </code></pre>
  
  <p>and </p>
  
  <pre><code>E/LOG﹕ Error: org.json.JSONException: Value You of type java.lang.String cannot be converted to JSONObject
  </code></pre>
  
  <p>That's my PHP code:</p>
  
  <pre><code>&lt;?php
  # Inform which carachters type will be used.
  header('Content-Type: text/html; charset=utf-8');
   // array for JSON response
  $response = array();
  
  // include db connect class
  
  require_once ('../conn.php');
  require_once('pClass.php');
  
  error_reporting( E_ALL ); 
  
  // connecting to db
  $db = new DB_CONNECT();
  
  //Setting to UTF8
  mysql_query("SET NAMES 'utf8_general_ci'");
  mysql_query('SET character_set_connection=utf8_general_ci');
  mysql_query('SET character_set_client=utf8_general_ci');
  mysql_query('SET character_set_results=utf8_general_ci');
  mysql_query('SET CHARACTER SET utf8');
  
      $ff_error = "ERROR";
      $arrPOI["arrPOI"] = array();
      $poi=new POI();
  
  if (isset($_REQUEST["ff_01"])) 
  {
      //Execute the query
      $ff_01 = $_REQUEST['ff_01'];
      $return = mysql_query($ff_01) or die(mysql_error());
  
      // check for empty result
      if (mysql_num_rows($return) &gt; 0) {
          while ($row = mysql_fetch_array($return)) {
              $poi-&gt;setPOIId($row["intPointId"]);
              $poi-&gt;setPOIName($row["vchPointName"]);
              $poi-&gt;setPOIImage($row["vchAwesomeFont"]);
              $poi-&gt;setStatusId($row["intStatusId"]);
              $poi-&gt;setLanguageId($row["intLanguageId"]);
  
              // push single category into final response array
              array_push($arrPOI["arrPOI"], $poi-&gt;getPOIData());
          }
          // echoing JSON response
          header('Content-Type: application/json');
          echo json_encode($arrPOI, JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK | JSON_NUMERIC_CHECK);
      } else {
          //No data found
          array_push($arrPOI["arrPOI"], $poi-&gt;getPOIData());
  
          // echo no users JSON
          header('Content-Type: application/json');
          echo json_encode($arrPOI);
      }
  } else {
      //ERROR
      array_push($arrPOI["arrPOI"], $poi-&gt;getPOIData());
  
      //Echo
      header('Content-Type: application/json');
      echo json_encode($arrPOI);
  }   
  ?&gt;
  </code></pre>
  
  <p>The PHP result:</p>
  
  <pre><code>{"arrPOI":[{"intPOIId":1,"strPOIName":"Cinema","strPOIImage":"fa-film","intStatusId":1,"intLanguageId":1},{"intPOIId":2,"strPOIName":"Teatro","strPOIImage":"fa-smile-o|fa-frown-o","intStatusId":1,"intLanguageId":1},{"intPOIId":3,"strPOIName":"Restaurante","strPOIImage":"fa-cutlery","intStatusId":1,"intLanguageId":1},{"intPOIId":4,"strPOIName":"Bar","strPOIImage":"fa-beer","intStatusId":1,"intLanguageId":1},{"intPOIId":5,"strPOIName":"Pontos TurÃ­sticos","strPOIImage":"fa-map-marker","intStatusId":1,"intLanguageId":1},{"intPOIId":6,"strPOIName":"Cafeteria","strPOIImage":"fa-coffee","intStatusId":1,"intLanguageId":1},{"intPOIId":7,"strPOIName":"Shopping","strPOIImage":"fa-diamond","intStatusId":1,"intLanguageId":1},{"intPOIId":8,"strPOIName":"Livraria","strPOIImage":"fa-book","intStatusId":1,"intLanguageId":1},{"intPOIId":9,"strPOIName":"Show","strPOIImage":"fa-microphone","intStatusId":1,"intLanguageId":1},{"intPOIId":10,"strPOIName":"Boates","strPOIImage":"fa-glass","intStatusId":1,"intLanguageId":1},{"intPOIId":11,"strPOIName":"Lanchonete","strPOIImage":"fa-cutlery","intStatusId":1,"intLanguageId":1},{"intPOIId":12,"strPOIName":"HotÃ©is","strPOIImage":"fa-building","intStatusId":1,"intLanguageId":1},{"intPOIId":13,"strPOIName":"Pub","strPOIImage":"fa-beer","intStatusId":1,"intLanguageId":1},{"intPOIId":14,"strPOIName":"Pizzaria","strPOIImage":"fa-pie-chart","intStatusId":1,"intLanguageId":1},{"intPOIId":15,"strPOIName":"Univesidade","strPOIImage":"fa-university","intStatusId":1,"intLanguageId":1},{"intPOIId":16,"strPOIName":"Hospital","strPOIImage":"fa-plus-square","intStatusId":1,"intLanguageId":1}]}
  </code></pre>
  
  <p>And my Java Code:</p>
  
  <pre><code>import com.android.volley.NoConnectionError;
  import com.android.volley.ServerError;
  import com.game.code.guide44.adapter.POIAdapter;
  import com.game.code.guide44.app.AppController;
  import com.game.code.guide44.data.PointOfInterest;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import com.android.volley.Request.Method;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.VolleyLog;
  import com.android.volley.toolbox.JsonObjectRequest;
  
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.ListView;
  import android.widget.Toast;
  
  public class POIChoose extends Activity {
      private ListView lVwPOI;
      private POIAdapter adapterPOI;
      private ProgressDialog pDialog;
      private List&lt;PointOfInterest&gt; POIList;
      private String url;
      private StringBuilder stbCheckedPOI;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_poi_choose);
          //Initialize with ListView object from  activity_poi_choose by id
          lVwPOI = (ListView)findViewById(R.id.lvwPOI);
          //Initialize the list of POI
          POIList = new ArrayList&lt;PointOfInterest&gt;();
          //initialize with POI List
          adapterPOI = new POIAdapter(this, POIList);
          //Fill the LiistView with POIAdapter content
          lVwPOI.setAdapter(adapterPOI);
          stbCheckedPOI = new StringBuilder();
          //Base url
          //Change "1" to dynamic user language
          url = getString(R.string.urlBase)+getString(R.string.urlGetPOI)+"?ff_01="+String.format(getString(R.string.sqlSelectPOI), "1");
  
          //Initialize the ProgressDialog
          pDialog = new ProgressDialog(POIChoose.this);
          //Show the progress bar befores making HTTP request
          pDialog.setMessage(getString(R.string.txtMsgPleaseWait));
          pDialog.show();
  
          // making fresh volley request and getting json
          JsonObjectRequest jsonReq = new JsonObjectRequest(Method.GET,
                  url, null, new Response.Listener&lt;JSONObject&gt;() {
  
              @Override
              public void onResponse(JSONObject response) {
                  VolleyLog.v("VOLLEY", "Response: " + response.toString());
                  if (response != null) {
                      parseJsonFeed(response);
                  }
              }
          }, new Response.ErrorListener() {
  
              @Override
              public void onErrorResponse(VolleyError error) {
                  if(error instanceof NoConnectionError)
                      Toast.makeText(POIChoose.this, "No internet available", Toast.LENGTH_SHORT).show();
                  else if(error instanceof ServerError)
                      Toast.makeText(POIChoose.this, "Server Error", Toast.LENGTH_SHORT).show();
  
                  VolleyLog.e("VOLLEY_ERROR", "Error: " + error.getMessage());
                  Log.e("LOG", "Error: " + error.getMessage());
                  pDialog.dismiss();
              }
          });
  
          // Adding request to volley request queue
          AppController.getInstance().addToRequestQueue(jsonReq);
      }
  
      @Override
      public void onDestroy() {
          super.onDestroy();
          hidePDialog();
      }
  
      private void hidePDialog() {
          if (pDialog != null) {
              pDialog.dismiss();
              pDialog = null;
          }
      }
  
      private void parseJsonFeed(JSONObject response){
          try{
              JSONArray jsonArray = response.getJSONArray("arrPOI");
                  for (int i = 0; i &lt; response.length(); i++) {
                      JSONObject jsonObject = (JSONObject) jsonArray.get(i);
                      PointOfInterest Poi = new PointOfInterest();
                      Poi.setPOIId(jsonObject.getInt("intPointId"));
                      Poi.setPOIName(jsonObject.getString("vchPointName"));
                      Poi.setPOIPicture(jsonObject.getString("vchAwesomeFont"));
                      Poi.setStatusId(jsonObject.getInt("intStatusId"));
                      Poi.setLanguageId(jsonObject.getInt("intLanguageId"));
  
                      // adding movie to movies array
                      POIList.add(Poi);
                  }
  
          } catch(JSONException e){
              e.printStackTrace();
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_first_choose, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      public void performSelectPOI(View view){
          for(int i = 0; i &lt; POIList.size(); i++)
          {
              if(adapterPOI.mCheckStates.get(i)==true)
              {
                  stbCheckedPOI.append(POIList.get(i).toString());
                  stbCheckedPOI.append("\n");
              }
              else
              {
  
              }
          }
          Toast.makeText(AppController.getContext(), stbCheckedPOI, Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>I also heard about <strong><em>GSON</em></strong>. Is it the solution? Can anyone help me? Thanks in advance!!</p>