public enum EnumType {
A, B;
@Override
public String toString() {
return name().toLowerCase();
}
}
public class Mock {
@JSONField(serialzeFeatures = {SerializerFeature.WriteEnumUsingToString})
private EnumType type;
public EnumType getType() {
return type;
}
public void setType(EnumType type) {
this.type = type;
}
}
public class Test {
@Test
public void test() {
Mock mock = new Mock();
mock.setType(EnumType.A);
Assert.assertEquals("{\"type\":\"a\"}", JSON.toJSONString(mock));
}
}
暂无答案!
目前还没有任何答案,快来回答吧!