Comments (7)
from hutool.
尝试使用JSONUtil.putDeserializer
,自定义反序列化。
from hutool.
尝试使用
JSONUtil.putDeserializer
,自定义反序列化。
追过链路并不行 cn.hutool.json.serialize.GlobalSerializeMapping#getDeserializer 内部缓存的key是type对象。 如果我自己put(new TypeReference<Map<String,Object>>(){},()->{}) ; key值的对象和反序列时候的targetType并不是一个对象。 导致取到的反序列化Deserializer为空。
感觉这里取Deserializer时应该把type转为string
from hutool.
@gg159753 我想你应该传Map.class,这样是处理所有Map。
from hutool.
key传Map.class 不行。 反序列化时候取的是type
from hutool.
Type type = (new TypeReference<Map<String, Object>>(){}).getType(); JSONUtil.putDeserializer(type, (JSONDeserializer<Map<String, Object>>) json -> { System.out.println("aaaaaaa"); return new HashMap(); });
这样可以了 不追代码真不知道。。。感觉取Deserializer时把type转为string 更好一点
from hutool.
@gg159753 这里确实比较繁琐,不过使用String貌似泛型稍有差异也会不匹配。
from hutool.
Related Issues (20)
- BeanUtil toBean 转换错误 HOT 6
- JSON字符串包含特殊字符的转义问题 HOT 3
- YamlUtil.dump写入文件之后第一行会有个!!xxxx这个东西,怎么去掉? HOT 1
- DateUtil between优化及formatBetween格式化精度丢失bug? HOT 1
- JSONUtil.toList导致内存泄漏 HOT 1
- jdk17以后javax 包部分迁移至jakarta 请适配 HOT 1
- [feature] 希望可以在StrUtil中增加 addArondIfNot 方法 HOT 1
- RuntimeUtil.exeForstr 执行psexe 获取不到日志 HOT 2
- TreeUtil扩展 HOT 1
- HttpUtil#downloadBytes(String url)无法传超时时间导致线程阻塞 HOT 10
- FileUtil.copyFile()实际效果与注释不一致 HOT 1
- [Hutool-Captcha] 无法生成透明背景的验证码 HOT 1
- 请问一下HttpUtil executeAsync方式是否需要手动关闭 HOT 3
- xml转jsonobject,xml标签中的字符串&被转成了& HOT 1
- 使用outlook账号密码发送邮件失败 HOT 3
- .JSONObject#putByPath 方法传入的路径表达式中存在纯数字字符串生成的 json 对象有问题 HOT 2
- isAM()无法正确识别centOS系统的时间 HOT 2
- JDK21 环境下 ClassUtil.scanPackage 失效 HOT 1
- DateUtil在使用graalvm打包native之后,会有时区问题 HOT 1
- ScrpitUtils运行js脚本无法进行读取的require关键字 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hutool.