public static JSONObject getJSONFromUrlViaGET(String url) {

        JSONObject jObj = null;

        StringBuilder builder = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        try {
            HttpResponse response = client.execute(httpGet);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    builder.append(line);
                }

                jObj = new JSONObject(builder.toString());
            } else {
                // Log.e(ParseJSON.class.toString(), "Failed to download file");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jObj;
    }
public static JSONObject getJSONFromUrlViaGET ( String url ) { JSONObject jObj = null ; StringBuilder builder = new StringBuilder ( ) ; HttpClient client = new DefaultHttpClient ( ) ; HttpGet httpGet = new HttpGet ( url ) ; try { HttpResponse response = client . execute ( httpGet ) ; StatusLine statusLine = response . getStatusLine ( ) ; int statusCode = statusLine . getStatusCode ( ) ; if ( statusCode == 200 ) { HttpEntity entity = response . getEntity ( ) ; InputStream content = entity . getContent ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( content ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { builder . append ( line ) ; } jObj = new JSONObject ( builder . toString ( ) ) ; } else { } } catch ( ClientProtocolException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } return jObj ; }
Queries the given URL with a GET request

@param url the url to query
@return the result JSON