This repository was archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
一个继承异常类,包含枚举值时,反序列化失败。 #3217
Copy link
Copy link
Closed
Milestone
Description
@Test
public void testException(){
MyException myException = new MyException();
myException.enumTest = EnumTest.FIRST;
TestClass testClass = new TestClass();
testClass.setMyException(myException);
String jsonString = JSON.toJSONString(testClass,SerializerFeature.NotWriteDefaultValue);
System.out.println(jsonString);
TestClass testClass1 = JSON.parseObject(jsonString, TestClass.class);
System.out.println(testClass1);
}
public static enum EnumTest{
FIRST("111","111"),
SECOND("222","222");
private String key;
private String value;
EnumTest(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
public static class MyException extends Exception{
private EnumTest enumTest;
public EnumTest getEnumTest() {
return enumTest;
}
public void setEnumTest(EnumTest enumTest) {
this.enumTest = enumTest;
}
}
public static class TestClass{
private MyException myException;
public MyException getMyException() {
return myException;
}
public void setMyException(MyException myException) {
this.myException = myException;
}
}
JDK:1.8.0_161
fastjson:1.2.61
Metadata
Metadata
Assignees
Labels
No labels