Making a web request and getting request in JSON format in android
I am trying to accomplish the task of
Making a Web request ->getting result in JSON format ->Parsing the result 开发者_Python百科 -> and finally display the result in a table....
Any help regarding any of the task is welcome....
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());
精彩评论