java 嵌套json如何转成list集合 10C

#嵌套json
jsonstr="{
"grade":"一班",
"studentnum":"3",
"student":[{
"xh":"0313001",
"name":"zhangsan",
"chengji": [{"ceyan":"one","yuwen":"71","shuxue":"72","yingyu":"73"},{"ceyan":"two","yuwen":"76","shuxue":"77","yingyu":"78"}],
"xh":"0313002",
"name":"lisi",
"chengji":[{"ceyan":"one","yuwen":"81","shuxue":"82","yingyu":"83"},{"ceyan":"one","yuwen":"86","shuxue":"87","yingyu":"88"}],
"xh":"0313003",
"name":"wangswu",
"chengji":[{"ceyan":"one","yuwen":"91","shuxue":"92","yingyu":"93"},{"ceyan":"one","yuwen":"96","shuxue":"97","yingyu":"98"}]
}]
}"

#定义的JavaBean实体类
public class JsonRootBean {

private String grade;
private String studentnum;
private List<Student> student;
public void setGrade(String grade) {
     this.grade = grade;
 }
 public String getGrade() {
     return grade;
 }

public void setStudentnum(String studentnum) {
     this.studentnum = studentnum;
 }
 public String getStudentnum() {
     return studentnum;
 }

public void setStudent(List<Student> student) {
     this.student = student;
 }
 public List<Student> getStudent() {
     return student;
 }

}

public class Student {

private String xh;
private String name;
private List<Chengji> chengji;
public void setXh(String xh) {
     this.xh = xh;
 }
 public String getXh() {
     return xh;
 }

public void setName(String name) {
     this.name = name;
 }
 public String getName() {
     return name;
 }

public void setChengji(List<Chengji> chengji) {
     this.chengji = chengji;
 }
 public List<Chengji> getChengji() {
     return chengji;
 }

}

public class Chengji {

private String cyss;
private String yuwen;
private String shuxue;
private String yingyu;
public void setCyss(String cyss) {
     this.cyss = cyss;
 }
 public String getCyss() {
     return cyss;
 }

public void setYuwen(String yuwen) {
     this.yuwen = yuwen;
 }
 public String getYuwen() {
     return yuwen;
 }

public void setShuxue(String shuxue) {
     this.shuxue = shuxue;
 }
 public String getShuxue() {
     return shuxue;
 }

public void setYingyu(String yingyu) {
     this.yingyu = yingyu;
 }
 public String getYingyu() {
     return yingyu;
 }

}

#该如何转换啊?

11个回答

jackson gson 随便一个json转换包都可以,查下api就行

共11条数据 首页 2
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问