ping8080 发表于 2013-1-14 18:23:26

处女apk纠结过的技术点<2>

                                                         android  json 解析
android自带json解析类,和java的使用有那么点区别,主要在实例化的时候 看代码
public static JSONArray jsonAnalyze(String result) {  
  JSONObject jsonObj;
  try {
   jsonObj = new JSONObject(result);//直接实例化
   String suc = jsonObj.getString("success");
   Log.i("success", suc);
   int count = jsonObj.getInt("totalCount");
   Log.i("totalCount", String.valueOf(count));
   JSONArray jobjData = jsonObj.getJSONArray("rows");    //解析获取数组
   return jobjData;
  } catch (JSONException e1) {
   e1.printStackTrace();
   return null;
  }
 }
页: [1]
查看完整版本: 处女apk纠结过的技术点<2>