-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
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-json toBean后的对象在dubbo3协议下传输序列化异常 #3477
Comments
尝试使用 |
追过链路并不行 cn.hutool.json.serialize.GlobalSerializeMapping#getDeserializer 内部缓存的key是type对象。 如果我自己put(new TypeReference<Map<String,Object>>(){},()->{}) ; key值的对象和反序列时候的targetType并不是一个对象。 导致取到的反序列化Deserializer为空。 |
@gg159753 我想你应该传Map.class,这样是处理所有Map。 |
这样可以了 不追代码真不知道。。。感觉取Deserializer时把type转为string 更好一点 |
@gg159753 这里确实比较繁琐,不过使用String貌似泛型稍有差异也会不匹配。 |
版本情况
JDK版本: openjdk_8_201
hutool版本: 5.8.25(请确保最新尝试是否还有问题)
问题描述(包括截图)
使用JSONUtil.toBean(s1,class)直接作为dubbo接口的返回。
在返回对象中有一个Map<String, Object>参数。 对端收到的JSONObject变成了JSONObject的config和raw
是由于dubbo3后面的版本默认使用fastjson2作为序列化方案。
追了一下堆栈应该是fastjson2构造JSONObject时调用了无参构造器再塞值导致多了一层raw
想请问一下有没有什么解决方案。 或者JSONUtil.toBean(s1,class)有办法把未知对象不转成JSONObject而是Map吗
The text was updated successfully, but these errors were encountered: