回答
分析當前的JSON字符串爲:
public class JSONTask extends
AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... arg) {
String linha = "";
String retorno = "";
// Cria o cliente de conexão
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet("https://graph.facebook.com
/fql?q=SELECT+app_id,namespace,category+
FROM+application+WHERE+namespace=graffitiwall%22");
try {
HttpResponse response = client.execute(get);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) { // Ok
BufferedReader rd = new BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
while ((linha = rd.readLine()) != null) {
retorno += linha;
}
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return retorno;
}
@Override
protected void onPostExecute(String result) {
// Create here your JSONObject...
// getting JSON string from URL
JSONObject json = new JSONObject(result);
// Getting Array of data
JSONArray userlist = json.getJSONArray("data");
for(int i = 0; i < userlist.length(); i++){
JSONObject c = userlist.getJSONObject(i);
// Storing each json item in variable
String str_app_id = c.getString("app_id");
String str_namespace = c.getString("namespace");
String str_category = c.getString("category");
}
}
是我的網址是否正確? JSONObject json = new JSONObject(「https://graph.facebook.com/fql?q=SELECT+app_id,namespace,category+FROM+application+WHERE+namespace=graffitiwall」); – teekib
@teekib:從服務器獲取沒有親愛的傳遞字符串。只是等待我編輯我的代碼與http也。張貼我的網址 –
https://graph.facebook.com/fql?q=SELECT+app_id,namespace,category+FROM+application+WHERE+namespace=graffitiwall – teekib
- 1. JSON解析不使用URL來讀取android中的json文件
- 2. Android JSON解析URL
- 3. 解析JSON屬性
- 4. 如何解析使用android的json url?
- 5. 使用Javascript解析JSON來自URL
- 6. Android SDK:使用GSON從URL解析JSON
- 7. 使用NSJSONSerialization解析JSON屬性
- 8. 如何使用GSON解析JSON與Android中的字段屬性
- 9. 從URL解析Android JSON
- 10. Android從url解析json
- 11. 使用Java讀取/解析JSON
- 12. JSON解析問題(獲取屬性)
- 13. 無法解析json屬性
- 14. 解析JSON URL
- 15. 解析json url
- 16. JSON解析後無法讀取未定義的屬性
- 17. autoit讀取/解析Json
- 18. 用PHP JSON解碼JSON解析URL
- 19. 讀解析JSON
- 20. 使用PHP解析URL中的JSON
- 21. 從Android Studio中的URL解析Json
- 22. JSON解析錯誤:無法讀取屬性
- 23. 解析JSON數據並讀取其屬性值
- 24. 解析Java中的JSON url
- 25. 使用API解析Android JSON
- 26. Android Json使用Gson解析
- 27. Json在Android中從URL解析
- 28. JSON解析Android中
- 29. Swift解析來自url的JSON
- 30. 解析來自URL的JSON數據
使用JSON解析器或GSON – Tobrun