标签:new 解析json span print obj gets throws hang class
public void jsonParse() throws JSONException{ String jsonStr = "{‘name‘:‘zhangsan‘,‘age‘:‘19‘}"; JSONObject jobj = new JSONObject(jsonStr); String name = jobj.getString("name"); // String age = jobj.getString("age"); int age = jobj.getInt("age"); System.out.println(name+"age = "+age); String jsonArr = "[{‘name‘:‘zhangsan‘,‘age‘:‘19‘},{‘name‘:‘lisi‘,‘age‘:‘29‘}]"; JSONArray jarr = new JSONArray(jsonArr); for(int i = 0;i<jarr.length();i++){ JSONObject jsonObject = jarr.getJSONObject(i); name = jsonObject.getString("name"); System.out.println(name); } }
标签:new 解析json span print obj gets throws hang class
原文地址:http://www.cnblogs.com/Oldz/p/6683374.html