JSONObject result = JSON.parseObject(responseData);
JSONObject data = result.getJSONObject("data");
String token = data.getString("token");
JSONArray jsonArray=gpsJsonObject.getJSONArray("points");
这样用起来也挺爽的
for (int i = 0; i < jsonArr.size(); i++) {
JSONObject jsonObject = jsonArr.getJSONObject(i);
String name = jsonObject.getString("name");
Integer age = (Integer) jsonObject.get("age");
System.out.println("name:"+name+";age:"+age);
}
String s="[{\"name\":\"7190214\"},{\"name\":\"7190208\"},{\"name\":\"6811009\"},{\"name\":\"7040177\"},{\"name\":\"7070152\"},{\"name\":\"7060188\"},{\"name\":\"7050156\"},{\"name\":\"7020169\"},{\"name\":\"7010202\"}]";
JSONArray dists = JSONArray.parseArray(s);
System.out.println(dists);
Set<String> list=new HashSet<>();
dists.stream().filter(Objects::nonNull).forEach(dist->{
list.add(((JSONObject) dist).getString("name"));
});
System.out.println(list);