首先我们有一个Student类:
package com.dusk.json;
/**
* Created by dushangkui on 2017/5/3.
*/
public class Student {
private String name;
private SexEnum sex;
public Student(String name, SexEnum sex) {
this.name = name;
this.sex = sex;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public SexEnum getSex() {
return sex;
}
public void setSex(SexEnum sex) {
this.sex = sex;
}
}
其中SexEnum是一个关于性别的枚举:
package com.dusk.json;
/**
* Created by dushangkui on 2017/5/3.
*/
public enum SexEnum {
Female(1,"女"),
Male(2,"男");
private int code;
private String desc;
private SexEnum(int code, String desc){
this.code=code;
this.desc=desc;
}
public