We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
简要描述您碰到的问题。 在反序列化包含hutool的Tree的List的java bean时,会丢失数据,但用jackson反序列化则正常
请填写以下信息:
如何操作可以重现该问题:
xxx.xxx
...
import cn.hutool.core.lang.tree.Tree; import java.io.Serializable; import java.util.List; public class DemoVO2 implements Serializable { private static final long serialVersionUID = 1L; List<Tree<String>> treeList; public List<Tree<String>> getTreeList() { return treeList; } public void setTreeList(List<Tree<String>> treeList) { this.treeList = treeList; } }
main方法测试如下
public static void main(String[] args) throws JsonProcessingException { String jsonString = "{\"treeList\":[{\"name\":\"name\",\"id\":\"1\",\"extra\":\"extra\"}]}"; JSONObject jsonObject = JSON.parseObject(jsonString); JSONArray array = jsonObject.getJSONArray("treeList"); array.forEach((v)-> System.out.println("JSONArray ==> "+v)); DemoVO2 vo2 = JSON.parseObject(jsonString, DemoVO2.class); List<Tree<String>> list = vo2.getTreeList(); System.out.println("parseObject ==> " + JSON.toJSONString(list)); System.out.println("***********************************************************"); DemoVO2 read = new ObjectMapper().readValue(jsonString, DemoVO2.class); List<Tree<String>> list1 = read.getTreeList(); System.out.println("jackson ==> " + JSON.toJSONString(list1)); }
结果如下:
JSONArray ==> {"name":"name","id":"1","extra":"extra"} parseObject ==> [{"name":"name","id":"1"}] *********************************************************** jackson ==> [{"name":"name","id":"1","extra":"extra"}]
数据正常输出
请复制并粘贴任何相关的日志输出。
The text was updated successfully, but these errors were encountered:
补充:如果直接使用parseObject(text),debug时,里面的数据也是正常的,只有后面带class的时候会出现这种情况:parseObject(String text, Class clazz)
Sorry, something went wrong.
fix hutool's Tree deserialization data loss,issue alibaba#2375
16690f1
https://github.com/alibaba/fastjson2/releases/tag/2.0.49 问题已修复,请用新版本
No branches or pull requests
问题描述
简要描述您碰到的问题。
在反序列化包含hutool的Tree的List的java bean时,会丢失数据,但用jackson反序列化则正常
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
xxx.xxx
方法...
数据...
错误main方法测试如下
结果如下:
其中JSONArray 解析出来的是正确的,parseObject 会丢失数据
期待的正确结果
数据正常输出
相关日志输出
请复制并粘贴任何相关的日志输出。
附加信息
在dubbo3.2.11下,DemoVO2 这种类同样存在丢失问题,从provider到comsumer List里面的Tree就是没有具体数据的Tree了,但是如果直接返回的List<Tree>则数据正常
The text was updated successfully, but these errors were encountered: