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

使用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);
posted @ 2023-09-06 14:03  尐海爸爸  阅读(662)  评论(0编辑  收藏  举报