标签:
1)例子如{"id":"334E654000F1A85CC10798C019433B7B"} 是该String jsonString;的值
public void ParseJson(String jsonString) throws JSONException, ParseException { JSONObject jo = new JSONObject(jsonString); String strId = jo.getString("id"); if(strToken != ""){ Log.e("Test","token:"+strId ); } }
2)例子如 [{"id":1,"name":"joke"},{"id":2,"name":"ken"}] 是该String jsonString;的值
public void ParseJson(String jsonString) throws JSONException, ParseException { JSONArray jsonArray = new JSONArray(jsonString); for (int i = 0; i < jsonArray.length(); i++) { JSONObject item = jsonArray.getJSONObject(i); int id = item.getInt("id"); String name = item.getString("name"); } }
标签:
原文地址:http://blog.csdn.net/loveheronly/article/details/44177145