Example #1
0
      @Override
      public List<String> handleResponse(HttpResponse response)
          throws ClientProtocolException, IOException {

        String JSONResponse = new BasicResponseHandler().handleResponse(response);
        try {

          JSONObject responseObject = (JSONObject) new JSONTokener(JSONResponse).nextValue();

          JSONArray values = responseObject.names();
          JSONArray weather = responseObject.toJSONArray(values);

          for (int idx = 0; idx < weather.length(); idx++) {

            JSONObject weatherObj = weather.getJSONObject(idx);

            // result
            result.add(
                NAME
                    + ": "
                    + weatherObj.get(NAME)
                    + "\n"
                    + "\n"
                    + LATITUDE
                    + ": "
                    + weatherObj.getString(LATITUDE)
                    + "\n"
                    + "\n"
                    + LONGITUDE
                    + ": "
                    + weatherObj.get(LONGITUDE)
                    + " F'"
                    + "\n"
                    + "\n"
                    + AREA
                    + ": "
                    + weatherObj.get(AREA));
          }

        } catch (JSONException e) {
          e.printStackTrace();
        }

        return result;
      }