2010-04-09 48 views
2

我试图完成的制作一个web请求,并在获得请求JSON格式的android

任务制作Web请求 - >获得结果JSON格式 - >解析结果 - >最后在表中显示的结果....

任何有关的任何任务是受欢迎的帮助....

+0

发布您已经编写的代码。 – 2010-04-09 12:34:48

+0

HttpClient或URLConnection - >呃?服务应该返回这个 - > Gson或JSONObject - >使用适配器 – Steve 2010-04-09 12:39:15

回答

8

我将离开你显示的结果,但第一位可如下完成:

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()); 
+0

+1以获得很好的答案。如果有人能够枚举JSON对象的例子,那将是完美的。 – Subby 2014-04-29 15:53:09