JSONObject类
string为json格式的字符串
JSONObject jsonObject = new JSONObject(string);
JSONObject对象的方法
jsonObject.getString("");
jsonObject.get("");
jsonObject.getJSONArray("");
jsonObject.getJSONObject("");
jsonObject.length();
jsonObject.has("key");//返回布尔值,判断是否有key
JSONArray类
JSONArray jsonArray=new JSONArray(response);
常用方法
jsonArray.get(int index);
注意get方法里面是int型值
本文介绍了如何使用JSONObject和JSONArray处理JSON格式的数据,包括创建JSON对象、获取数据等操作,并提供了具体的使用示例。
1278

被折叠的 条评论
为什么被折叠?



