JSON例子

来源:互联网 发布:vscode js快捷键 编辑:程序博客网 时间:2024/03/29 07:14
static VechilceListBean getVechilceListBean(String str)throws JSONException {JSONObject json = new JSONObject(str);VechilceListBean bean = new VechilceListBean();List<ACBTarget> vehicleList = new ArrayList<ACBTarget>();bean.setC(json.getInt("c"));bean.setM(json.getString("m"));bean.setSessionid(json.getString("sessionid"));JSONArray vhcArray = json.getJSONArray("vehicleList");for (int i = 0; i < vhcArray.length(); i++) {ACBTarget target = new ACBTarget();JSONObject j = vhcArray.getJSONObject(i);target.setId(j.getLong("id"));target.setLid(j.getString("lid"));target.setLocked(j.getBoolean("locked"));target.setName(j.getString("name"));vehicleList.add(target);}bean.setVehicleList(vehicleList);return bean;}

 

引用org.json.jar