title: Only displaying connecting to server, not loading JSON data
body: <p>I'm trying to get some JSON data using <code>HttpURLConnection</code>, but I only get Connecting server displaying and nothing happens.</p>
  
  <p>This is my code:</p>
  
  <pre><code>@SuppressWarnings("deprecation")
  public class JSONParsingFragment extends Fragment{
      ListView lv;
      ArrayList&lt;Actors&gt; actorsList;
      ActorAdapter adapter;
  
      @Override
      public View onCreateView(LayoutInflater inflater,
                               @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  
          View vw=inflater.inflate(R.layout.jsonparse_fragment, container, false);
          lv=(ListView) vw.findViewById(R.id.listView1);
  
          actorsList = new ArrayList&lt;Actors&gt;();
          new JSONAsynTask().execute("http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors");
          adapter = new ActorAdapter(getActivity(), R.layout.jsonparsedata_item, actorsList);
          lv.setAdapter(adapter);
          return  vw;
      }
  
      class JSONAsynTask extends AsyncTask&lt;String, Void, Void&gt; {
          String result;
          ProgressDialog dialog;
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              dialog = new ProgressDialog(getActivity());
              dialog.setMessage("Loading, please wait");
              dialog.setTitle("Connecting server");
              dialog.show();
              dialog.setCancelable(false);
          }
  
          @Override
          protected Void doInBackground(String... strings) {
              URL url;
              HttpURLConnection urlConnection = null;
  
              try {
                  url = new URL(strings[0]);
                  urlConnection = (HttpURLConnection) url.openConnection();
                  int responseCode = urlConnection.getResponseCode();
  
                  if(responseCode == HttpURLConnection.HTTP_OK){
  
                      JSONObject jsono = new JSONObject(String.valueOf(url));
                      JSONArray jarray = jsono.getJSONArray("actors");
  
                      for (int i = 0; i &lt; jarray.length(); i++) {
                          JSONObject object = jarray.getJSONObject(i);
  
                          Actors actor = new Actors();
  
                          actor.setName(object.getString("name"));
                          actor.setDescription(object.getString("description"));
                          actor.setDob(object.getString("dob"));
                          actor.setCountry(object.getString("country"));
                          actor.setHeight(object.getString("height"));
                          actor.setSpouse(object.getString("spouse"));
                          actor.setChildren(object.getString("children"));
                          actor.setImage(object.getString("image"));
  
                          actorsList.add(actor);
  
                          Log.v("log", "response");
                      }
  
  
                  } } catch (IOException e) {
                  e.printStackTrace();
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
              return null;}
  
          protected void onPostExecute(Boolean result) {
  
              dialog.dismiss();
              adapter.notifyDataSetChanged();
              if(result == false)
                  Toast.makeText(getActivity(), "Unable to fetch data from server", Toast.LENGTH_LONG).show();
  
          }
      }
  
  }
  </code></pre>
  
  <p>In the console log I have:</p>
  
  <p><code>org.json.JSONException: Value http of type java.lang.String cannot be converted to JSONObject</code></p>
  
  <p>So it seems I have an error in this part:</p>
  
  <pre><code> if(responseCode == HttpURLConnection.HTTP_OK){
  
                          JSONObject jsono = new JSONObject(String.valueOf(url));
                          JSONArray jarray = jsono.getJSONArray("actors");
  </code></pre>
  
  <p>Can someone please help me with this?</p>