I tried the code in android below:-
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet("http://echo.jsontest.com/key/value/one/two");
String text = null;
try {
HttpResponse response = httpClient.execute(httpGet, localContext);
HttpEntity entity = response.getEntity();
text = getASCIIContentFromEntity(entity);
JSONArray jsonObj = new JSONArray(entity);
System.out.print("message is"+jsonObj);
}
catch (Exception e) {
return e.getLocalizedMessage();
}
return text;
//Below i am displaying in my layout in my emulator
protected void onPostExecute(String results) {
if (results!=null) {
TextView et = (TextView)findViewById(R.id.data);
et.setText(results);
}
Button b = (Button)findViewById(R.id.getvehicles);
b.setClickable(true);
}
so when i just use getASCIIContentFromEntity(entity) ,then i am able to print full JSON data as it is.but instead i wanna print only the values inside this URL it is JSON data,please open to see it .
How can i fetch the values inside this json URL?
JSONObject jsonObj = new JSONObject(entity.toString()); System.out.print("message is"+jsonObj.toString());