Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>while ((line = reader.readLine()) != null){ sb.append(line + "\n"); } </code></pre> <p>instead try</p> <pre><code>while ((line = reader.readLine()) != null){ sb.append(line); json = sb.toString().substring(0, sb.toString().length()-1); } </code></pre> <p>Follow this method for getting json object:</p> <pre><code> public JSONObject getJSONObjFromUrl(String url, List&lt;NameValuePair&gt; params) { System.out.println("url:: "+url ); System.out.println("params:: "+ params +" " +params.get(0) ); // Making HTTP request try { // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line); } is.close(); json = sb.toString().substring(0, sb.toString().length()-1); // Log.e("JSON:: ", json); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload