String object = "{'main':[{'name':'A','address':'ShanHai'},{'name':'B','address':'ShanHai'},{'name':'C','address':'ShanHai'},{'name':'D','address':'ShanHai'}]}";
JSONObject jsonObject = JSONObject.fromObject(object);
System.out.println(jsonObject);
List sbulist = jsonObject.getJSONArray("main").subList(0, 3);
System.out.println(sbulist);
jsonObject.put("main", sbulist);
System.out.println(jsonObject);
java 操作array、list 。subList 的使用
最新推荐文章于 2024-06-13 16:47:40 发布