求助:java中如何使用json-lib解析这种格式的json数据(list中嵌套list)?

2025-04-17 04:50:25
推荐回答(1个)
回答1:

JSONArray ccroot = jp.getJSONArray("城市代码");
for (int i = 0; i < ccroot.length(); i++) {
JSONObject o = (JSONObject) ccroot.get(i);
JSONArray county = o.getJSONArray("市");
for (int j = 0; j < county.length(); j++) {
weatherForecastDTO = new WeatherForecastDTO();
String countyName = county.getJSONObject(j).getString("市名");
String countyCode = county.getJSONObject(j).getString("编码");
}
}

自己对着改