前言
在使用FastJson时出现报错
错误信息如下:
syntax error, expect {, actual string, pos 0, fastjson-version 1.2.47
代码中我是先把对象进行序列化存入到Redis里面:
JSONObject.toJSONString(articleListVO,true);
然后从Redis里面取出:
String str = cmRedisTemplate.getStr(value);
JSONObject.parseObject(str, ArticleListVO.class);
出现报错,其实我们从Redis里面取出数据进行序列化后,需要添加如下操作:
String str = cmRedisTemplate.getStr(value);
String parse = (String) JSON.parse(str);
ArticleListVO articleListVO = JSONObject.parseObject(parse, ArticleListVO.class);