You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importcom.alibaba.fastjson2.*;
importcom.alibaba.fastjson2.util.ParameterizedTypeImpl;
importorg.junit.Test;
importjava.util.List;
/** * @author 张治保 * date 2023/5/8 */publicclassFastjsonTest {
@Testpublicvoidtest() {
List<TestEnum> enums = List.of(TestEnum.A, TestEnum.B);
JSONArrayarray = JSON.parseArray(JSON.toJSONString(enums));
List<TestEnum> result = array.to(newParameterizedTypeImpl(newClass[]{TestEnum.class}, null, List.class));
}
enumTestEnum {
A,
B
}
}
异常
com.alibaba.fastjson2.JSONException: can not convert from class java.lang.String to class top.rows.dubbo.test.consumer.FastjsonTest$TestEnum
at com.alibaba.fastjson2.reader.ObjectReaderImplList.createInstance(ObjectReaderImplList.java:251)
at com.alibaba.fastjson2.JSONArray.to(JSONArray.java:983)
at top.rows.dubbo.test.consumer.FastjsonTest.test(FastjsonTest.java:18)
The text was updated successfully, but these errors were encountered:
复现代码
异常
The text was updated successfully, but these errors were encountered: