[java]代码库
List<Area> list = .......
JSONObject json = new JSONObject(jsonstr);
String name = json.getString("name");
int area = json.getInt("area");
String renkou = ........
.....
Area result = new Area(name,area,renkou);
list.add(result);//源代码片段来自云代码http://yuncode.net
public class Area {
private String name;
private String area;
private String renkou;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getRenkou() {
return renkou;
}
public void setRenkou(String renkou) {
this.renkou = renkou;
}
}
String json = "[{name:\"北京\",area:\"16000\",renkou:\"1000万\"}, {name:\"上海\",area:\"10000\",renkou:\"1000万\"}]";
List<Area> areas = JSON.parseArray(json, Area.class);//源代码片段来自云代码http://yuncode.net