2

I am trying to accomplish the task of

Making a Web request ->getting result in JSON format ->Parsing the result -> and finally display the result in a table....

Any help regarding any of the task is welcome....

2
  • Post the code you already have written. Commented Apr 9, 2010 at 12:34
  • HttpClient or URLConnection -> Huh? Service should return this -> Gson or JSONObject -> Use Adapter Commented Apr 9, 2010 at 12:39

1 Answer 1

8

I'll leave you to display the results, but the first bit can be accomplished as follows:

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()); 
Sign up to request clarification or add additional context in comments.

1 Comment

+1 for a good answer. Would have been perfect if there was an example of how one can enumerate the JSON object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.