前言
在使用FastJson时出现报错

错误信息如下:
syntax error, expect {, actual string, pos 0, fastjson-version 1.2.47
1
代码中我是先把对象进行序列化存入到Redis里面:

 JSONObject.toJSONString(articleListVO,true);
1
然后从Redis里面取出:

 String str = cmRedisTemplate.getStr(value);
 JSONObject.parseObject(str, ArticleListVO.class);
1
2
出现报错,其实我们从Redis里面取出数据进行序列化后,需要添加如下操作:

         String str = cmRedisTemplate.getStr(value);
            String parse = (String) JSON.parse(str);
            ArticleListVO articleListVO = JSONObject.parseObject(parse, ArticleListVO.class);
————————————————
 

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐