Making a web request and receiving a JSON request in android

I am trying to complete the task

Create a web request -> get the result in JSON format -> Parse the results -> and finally display the result in a table ....

Any help on any task is appreciated ....

+2


source to share


1 answer


I'll leave you to display the results, but the first bit can be done like this:



URLConnection connection = new URL("http://example.com/someService.jsp").openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()), 1024 * 16);
StringBuffer builder = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
  builder.append(line).append("\n");
}
JSONObject object = new JSONObject(builder.toString()); 

      

+8


source







All Articles