解决 com.alibaba.fastjson.JSONException: autoType is not support.
2018-03-15 00:28
3143 查看
1、问题描述
升级fastjson的版本后,反序列化List集合时,报错:Exception in thread “???” com.alibaba.fastjson.JSONException: autoType is not support.2、问题产生原因
2017年3月15日,fastjson官方发布安全升级公告,该公告介绍fastjson在1.2.24及之前的版本存在代码执行漏洞,当恶意攻击者提交一个精心构造的序列化数据到服务端时,由于fastjson在反序列化时存在漏洞,可导致远程任意代码执行。自1.2.25及之后的版本,禁用了部分autotype的功能,也就是”@type”这种指定类型的功能会被限制在一定范围内使用。
而由于反序列化对象时,需要检查是否开启了autotype。所以如果反序列化检查时,autotype没有开启,就会报错。
@type出现在JSON字符串的场景: 当调用了 JSON.toJSONString(object, SerializerFeature.WriteClassName); 这个API时,会让生成的JSON字符串中含有 @type 的属性值 例如: {"@type":"全类名","age":10,"name":"张三"}
3、解决办法
官方给出了开启autotype的方法:enable_autotype相关文章推荐
- 解决com.alibaba.fastjson.JSONException: autoType is not support
- Exception in thread "main" com.alibaba.fastjson.JSONException: autoType is not support. com.accord.f
- com.alibaba.fastjson.JSONException: autoType is not support.
- com.alibaba.fastjson.JSONException: not close json text, token : error
- com.alibaba.fastjson.JSONException: not close json text, token : error
- com.alibaba.fastjson.JSONException: default constructor not found. class com.anerfa.axdblue_code.ho
- java.lang.ClassNotFoundException: com.alibaba.fastjson.JSON
- Caused by: java.lang.ClassNotFoundException: com.alibaba.fastjson.JSONObject
- nested exception is java.lang.NoClassDefFoundError: com/alibaba/fastjson/JSON
- Kotlin - com.alibaba.fastjson.JSONException: default constructor not found
- fastjson autotype is not support
- com.alibaba.fastjson.JSONException: default constructor not found. class ……
- kotlin使用com.alibaba.fastjson.JSONException: default constructor not found
- com.alibaba.fastjson.JSONException: not close json text, token : :
- 关于dubbo调度时出现Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method insertTestTb in the service cn.cuibusi.core.service.TestTbService.的解决办法
- 解决ERROR - unregister mbean error javax.management.InstanceNotFoundException: com.alibaba.druid:type=
- com.alibaba.fastjson.JSOnException:exepct '[' ,but {
- com.alibaba.fastjson.JSONException: error parse e
- com.alibaba.fastjson.JSOnException:exepct '[' ,but {object
- JsonObject(com.alibaba.fastjson)返回值修改后,源对象的值也发生改变解决方法