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