2010-04-09 47 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