0
로 열거 유형을 직렬화 I 기업이 내가 JSON으로 직렬화 또한 JSON에서 deserailizing하고있다 : 나는 주석이 원하는드/잭슨
public enum Status {
NEW,
ACTIVE,
PENDING,
ERROR;
}
: 같은
public class Item {
@JsonProperty private Status status;
....
}
상태 열거 보이는 예를 들어 {status : "NEW"}로 직렬화하고 열거 유형으로 역 직렬화하는 동일한 열거 유형. 이에 대한 별도의 주석이 있습니까?
@Override
@JsonValue
public String toString()
{
return super.toString().toUpperCase(Locale.ENGLISH);
}
@JsonCreator
public static Status fromString(final String status)
{
if (status == null)
{
return null;
}
try
{
return valueOf(status.toUpperCase(Locale.ENGLISH));
}
catch (IllegalArgumentException iae)
{
System.err.println("Invalid status");
}
}
이 또한 당신의 상태 변환이 대소 문자를 구분하지 (그래서 '새로운'상태가 여전히 올바른 열거로 변환 것)인지 확인 :
뛰어난! 고맙습니다. – badgerduke