4
在enum上的 @JSONField 在parse的时候起到了作用,但是在toString的时候,并没有使用name中指定的key, 仍然打印出 "type":"enumeration", 期望的是 "type":"enum"。
public class AttributeTypeDesc {
private AttributeType type;
/* setter getter */
}
enum AttributeType {
number,
string,
@JSONField(name = "enum")
enumeration;
}
AttributeTypeDesc typeEnum = JSON.parseObject("{\"type\":\"enum\"}", AttributeTypeDesc .class);
JSON.toJSONString(typeEnum)