首先在Maven中添加依赖,自动下载官方解析包
解析{"educates": [{"specialtyName": "\u901a\u4fe1\u5de5\u7a0b", "certificateName": "",}]}
JSONObject jb = JSONObject.parseObject(str);
先解析成json对象
然后提取educates
JSONArray ja = jb.getJSONArray("educates");
遍历数组中的大括号,继续提取:
for (Object oj : ja) { System.out.println(oj); JSONObject oj2 = (JSONObject) oj; String collegeName = oj2.getString("collegeName"); System.out.println(collegeName); }