I am sending the the data to server, and trying to parse the json response which is of the form {"count":"2"}, but I am getting above exception
This is my code
post(serverUrl, params);
HttpClient httpClient = new DefaultHttpClient();
try{
get = new HttpPost(url);
r = httpClient.execute(get);
he = r.getEntity();
InputStream is = he.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) { sb.append(line + "\n"); }
String result = sb.toString();
jObj = new JSONObject(result);
Log.d(TAG, "Count is" + jObj);
count = jObj.getString("count");
Log.d(TAG, "Count is" + count);
}
catch (Exception e) { e.printStackTrace(); }
There is possibility for blank value in response. It cannot consider as null.. This error because of blank response.