使用fastjson2将字符串转对象时当对象中有class属性时使用JSON.parseObject(jsonStr, xx.class)报错

发布时间 2023-09-06 14:06:58作者: 尐海爸爸

使用fastjson2将字符串转对象时当对象中有class属性时使用JSON.parseObject(jsonStr, ObjCacheDirectoryVo.class)报错

com.alibaba.fastjson2.JSONException: not support ClassForName : xxx, you can config 'JSONReader.Feature.SupportClassForName', offset 74, character ], line 1, column 75, fastjson-version 2.0.39

解决方案

JSON.parseObject(jsonStr, ObjCacheDirectoryVo.class, Feature.SupportClassForName);