我有一个 StepEnum,我想像这样生成 json:
{"success":true,"stepList":[{"name":"My First Step","index":0,"status":"active"},{"name":"My Second Step","index":1,"status":"inactive"}]}
但是我得到这样的输出:
{"success":true,"stepList":["MY_FIRST_STEP","MY_SECOND_STEP"]}
我需要在我的 Enum 类中进行哪些更改。Json 是由 spring 框架生成的。这是我的 StepEnum 类:
public enum StepEnum {
MY_FIRST_STEP("My First Step",0),
MY_SECOND_STEP("My Second Step",1);
private String label;
private int index;
private String status;
private StepEnum(String label, int index) {
this.label = label;this.index = index;
}
public void setIndex(int index) {
this.index = index;
}
public int getIndex() {
return index;
}
public void setLabel(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}