-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] 无法反序列化Class<?>对象 #369
Comments
2.x中,为更安全,缺省不支持,你可以通过JSONReader.Feature.SupportClassForName打开 Class<?> parse = JSON.parseObject(s, Class.class, JSONReader.Feature.SupportClassForName); |
对于带Class数组字段的对象还是无法正确反序列化 Class<?>[] arrays= new Class[] { String.class, HelloObject.class, String.class};
Wrapper wrapper=new Wrapper();
wrapper.setParameterTypes(arrays);
String s = JSON.toJSONString(wrapper);
System.out.println(s);
Wrapper parse = JSON.parseObject(s, Wrapper.class, JSONReader.Feature.SupportClassForName);
System.out.println(parse); |
2.0.6-SNAPSHOT已修复你的问题,可以先验证下,2.0.6版本预计在6月5日前会发布 |
测试完没问题了 |
问题描述
反序列化Class<?>对象时报错
Exception in thread "main" com.alibaba.fastjson2.JSONException: not support autoType :
at com.alibaba.fastjson2.reader.ObjectReaderImplClass.readObject(ObjectReaderImplClass.java:30)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:159)
环境信息
请填写以下信息:
重现步骤
The text was updated successfully, but these errors were encountered: