ITeye博客

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

ping8080 · 2011-02-28 11:50 · 移动开发 · Markdown

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;
  }
 }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。