title: Unable to parse JSON response in android studio
body: <p>I am trying to build a simple weather app. I am using forecast.io and just trying to extract the summary, temperature and precipitation. So far I have been able to get the response from the site but I am not able to parse it and log just the three values I mentioned above. Here is my logCat response:</p>
  
  <pre><code>12-12 13:55:45.528    1286-2153/system_process I/ActivityManager﹕ Start proc 25643:sidd.tisb.lms.sidsstudios.weather/u0a57 for activity sidd.tisb.lms.sidsstudios.weather/.MainActivity
  12-12 13:55:45.536  25643-25643/sidd.tisb.lms.sidsstudios.weather I/art﹕ Not late-enabling -Xcheck:jni (already on)
  12-12 13:55:45.539   1858-25629/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr﹕ Hotword detection finished
  12-12 13:55:45.539    1858-2248/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr﹕ Stopping hotword detection.
  12-12 13:55:45.685  25643-25643/sidd.tisb.lms.sidsstudios.weather W/System﹕ ClassLoader referenced unknown path: /data/app/sidd.tisb.lms.sidsstudios.weather-2/lib/x86
  12-12 13:55:45.888     942-1780/? E/SurfaceFlinger﹕ ro.sf.lcd_density must be defined as a build property
  12-12 13:55:45.891  25643-25664/sidd.tisb.lms.sidsstudios.weather D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
  12-12 13:55:45.894  25643-25643/sidd.tisb.lms.sidsstudios.weather D/﹕ HostConnection::get() New Host Connection established 0xb401c8a0, tid 25643
  12-12 13:55:45.952  25643-25664/sidd.tisb.lms.sidsstudios.weather D/﹕ HostConnection::get() New Host Connection established 0xab7bf010, tid 25664
  12-12 13:55:45.965  25643-25664/sidd.tisb.lms.sidsstudios.weather I/OpenGLRenderer﹕ Initialized EGL, version 1.4
  12-12 13:55:46.003  25643-25664/sidd.tisb.lms.sidsstudios.weather W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  12-12 13:55:46.003  25643-25664/sidd.tisb.lms.sidsstudios.weather W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xabdffbe0, error=EGL_SUCCESS
  12-12 13:55:46.123   1858-25660/com.google.android.googlequicksearchbox:search W/Search.SearchUrlHelper﹕ Auth token not ready, no auth header set.
  12-12 13:55:46.273    1286-1305/system_process I/ActivityManager﹕ Displayed sidd.tisb.lms.sidsstudios.weather/.MainActivity: +771ms
  12-12 13:55:46.281    1286-1298/system_process W/InputMethodManagerService﹕ Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@149f411 (uid=10014 pid=2154)
  12-12 13:55:46.302    2154-2219/com.google.android.googlequicksearchbox E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xb4013030
  12-12 13:55:47.802  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ org.json.JSONException: Value {"latitude":37.329586,"longitude":-122.027337,"timezone":"America\/Los_Angeles","offset":-8,"currently":{"time":1449908733,"summary":"Clear","icon":"clear-night","nearestStormDistance":32,"nearestStormBearing":39,"precipIntensity":0,"precipProbability":0,"temperature":47.6,"apparentTemperature":43.87,"dewPoint":42.72,"humidity":0.83,"windSpeed":7.94,"windBearing":329,"visibility":8.66,"cloudCover":0.19,"pressure":1017.02,"ozone":334.34},"minutely":{"summary":"Clear for the hour.","icon":"clear-night","data":[{"time":1449908700,"precipIntensity":0,"precipProbability":0},{"time":1449908760,"precipIntensity":0,"precipProbability":0},{"time":1449908820,"precipIntensity":0,"precipProbability":0},{"time":1449908880,"precipIntensity":0,"precipProbability":0},{"time":1449908940,"precipIntensity":0,"precipProbability":0},{"time":1449909000,"precipIntensity":0,"precipProbability":0},{"time":1449909060,"precipIntensity":0,"precipProbability":0},{"time":1449909120,"precipIntensity":0,"precipProbability":0},{"time":1449909180,"precipIntensity":0,"precipProbability":0},{"time":1449909240,"precipIntensity":0,"precipProbability":0},{"time":1449909300,"precipIntensity":0,"precipProbability":0},{"time":1449909360,"precipIntensity":0,"precipProbability":0},{"time":1449909420,"precipIntensity":0,"precipProbability":0},{"time":1449909480,"precipIntensity":0,"precipProbability":0},{"time":1449909540,"precipIntensity":0,"precipProbability":0},{"time":1449909600,"precipIntensity":0,"precipProbability":0},{"time":1449909660,"precipIntensity":0,"precipProbability":0},{"time":1449909720,"precipIntensity":0,"precipProbability":0},{"time":1449909780,"precipIntensity":0,"precipProbability":0},{"time":1449909840,"precipIntensity":0,"precipProbability":0},{"time":1449909900,"precipIntensity":0,"precipProbability":0},{"time":1449909960,"precipIntensity":0,"precipProbability":0},{"time":1449910020,"precipIntensity":0,"precipProbability":0},{"time":1449910080,"precipIntensity":0,"precipProbability":0},{"time":1449910140,"precipIntensity":0,"precipProbability":0},{"time":1449910200,"precipIntensity":0,"precipProbability":0},{"time":1449910260,"precipIntensity":0,"precipProbability":0},{"time":1449910320,"precipIntensity":0,"precipProbability":0},{"time":1449910380,"precipIntensity":0,"precipProbability":0},{"time":1449910440,"precipIntensity":0,"precipProbability":0},{"time":1449910500,"precipIntensity":0,"precipProbability":0},{"time":1449910560,"precipIntensity":0,"precipProbability":0},{"time":1449910620,"precipIntensity":0,"precipProbability":0},{"time":1449910680,"precipIntensity":0,"precipProbability":0},{"time":1449910740,"precipIntensity":0,"precipProbability":0},{"time":1449910800,"precipIntensity":0,"precipProbability":0},{"time":1449910860,"precipIntensity":0,"precipProbability":0},{"time":1449910920,"precipIntensity":0,"precipProbability":0},{"time":1449910980,"precipIntensity":0,"precipProbability":0},{"time":1449911040,"precipIntensity":0,"precipProbability":0},{"time":1449911100,"precipIntensity":0,"precipProbability":0},{"time":1449911160,"precipIntensity":0,"precipProbability":0},{"time":1449911220,"precipIntensity":0,"precipProbability":0},{"time":1449911280,"precipIntensity":0,"precipProbability":0},{"time":1449911340,"precipIntensity":0,"precipProbability":0},{"time":1449911400,"precipIntensity":0,"precipProbability":0},{"time":1449911460,"precipIntensity":0,"precipProbability":0},{"time":1449911520,"precipIntensity":0,"precipProbability":0},{"time":1449911580,"precipIntensity":0,"precipProbability":0},{"time":1449911640,"precipIntensity":0,"precipProbability":0},{"time":1449911700,"precipIntensity":0,"precipProbability":0},{"time":1449911760,"precipIntensity":0,"precipProbability":0},{"time":1449911820,"precipIntensity":0,"precipProbability":0},{"time":1449911880,"precipIntensity":0,"precipProbability":0},{"time":1449911940,"precipIntensity":0,"precipProbability":0},{"time":1449912000,"precipIntensity":0,"precipProbability":0},{"time":1449912060,"precipIntensity":0,"precipP
  12-12 13:55:47.802  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at org.json.JSON.typeMismatch(JSON.java:111)
  12-12 13:55:47.802  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at org.json.JSONArray.&lt;init&gt;(JSONArray.java:96)
  12-12 13:55:47.802  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at org.json.JSONArray.&lt;init&gt;(JSONArray.java:108)
  12-12 13:55:47.802  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at sidd.tisb.lms.sidsstudios.weather.MainActivity$getWeather.doInBackground(MainActivity.java:31)
  12-12 13:55:47.803  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at sidd.tisb.lms.sidsstudios.weather.MainActivity$getWeather.doInBackground(MainActivity.java:24)
  12-12 13:55:47.803  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:295)
  12-12 13:55:47.803  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  12-12 13:55:47.803  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
  12-12 13:55:47.803  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
  12-12 13:55:47.803  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
  12-12 13:55:47.803  25643-25663/sidd.tisb.lms.sidsstudios.weather W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
  </code></pre>
  
  <p>Here is my mainActivity code:</p>
  
  <pre><code>package sidd.tisb.lms.sidsstudios.weather;
  
  import android.app.Activity;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  public class MainActivity extends Activity {
      String url = ("https://api.forecast.io/forecast/fee692c335fd7e561223c520322731e1/37.329586,-122.027337");
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          new getWeather().execute();
      }
  
      class getWeather extends AsyncTask&lt;String, String,String&gt;{
  
          @Override
          protected String doInBackground(String... strings) {
              JsonGetter jsonGetter = new JsonGetter();
              String response = jsonGetter.getJSON(url);
              try {
                  JSONArray jsonArray = new JSONArray(response);
                  for (int i = 0; i&lt;jsonArray.length();i++){
                      JSONObject jsonObject = jsonArray.getJSONObject(i);
                      String summary = jsonObject.getString("summary");
                      String temperature = jsonObject.getString("temperature");
                      String rainProb = jsonObject.getString("precipProbability");
                      Log.e("Summary: ", summary );
                      Log.e("Temperature: ",temperature);
                      Log.e("Probability of rain: ", rainProb);
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
              return null;
          }
      }
  }
  </code></pre>
  
  <p>I know I haven't extracted the URL string from strings.xml or used URLConnection but this is just a test and I wasnt to know why the JSON is not getting parsed.
  Here is my JSONGEtter class:</p>
  
  <pre><code>package sidd.tisb.lms.sidsstudios.weather;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.util.EntityUtils;
  
  import java.io.IOException;
  
  /**
   * Created by Siddharth on 12/12/2015.
   */
  public class JsonGetter {
  
      String response;
  
      public String getJSON(String URL) {
          try {
              HttpGet httpGet = new HttpGet(URL);
              HttpClient httpClient = new DefaultHttpClient();
              HttpResponse httpResponse = httpClient.execute(httpGet);
              HttpEntity httpEntity = httpResponse.getEntity();
              response = EntityUtils.toString(httpEntity);
          } catch (IOException e) {
              e.printStackTrace();
          } {
  
          }
          return response;
      }
  }
  </code></pre>
  
  <p>Any ideas as to why I am not getting log statements displaying the summary, temperature and precipitation?
  Thanks!!!</p>