回答
分析当前的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