android Json数据解析
JSONObject jsonObject = new JSONObject(jsonutil.json); // jsonutil.json 接收到服务端传递的数据 JSONArray jsonArray = jsonObject.getJSONArray("list_allFoods"); //服务端的List数组名 for (int y = 0; y < jsonArray.length(); y++) { //数组接收方法 JSONObject json = (JSONObject) jsonArray.get(y); //y 为数组下标 0,1,2...... json.getString("属性名"); //数组中的对象接收方法 JSONObject food = json.getJSONObject("对象名"); JSONObject user = json.getJSONObject("对象名"); food.getString("属性名");
}
可将json数据存于字符串 或者 List<Object> 中 方便使用

浙公网安备 33010602011771号