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)
- FuncComparator.thenComparing 不生效 HOT 6
- BeanUtil支持list到bean对象的深拷贝吗?如果不支持,请问用什么方法可以list到bean对象的深拷贝? HOT 1
- 请问有没有时间相互转换的工具? HOT 3
- FileTypeUtil 在分析 DOCX,PPTX,XLSX 文件类型时, 会被 ZIP 逻辑处理掉,不能被DOCX,PPTX,XLSX的match方法处理 HOT 2
- VelocityEngine 模板引擎找不到文件 HOT 1
- 利用 JSR-305 元注释向支持 JSR-305 的常用工具指示 Java 中的可为空性 HOT 2
- Cannot read the array length because "<local3>" is null HOT 6
- 读取文件超过3GB时报java.lang.NegativeArraySizeException: -221445712 HOT 1
- 关于@Alias注解的一些使用建议 HOT 1
- NumberWordFormatter.format 只有1位小数转英文有BUG HOT 1
- BeanUtil.setProperty 希望表达式可以支持list直接设置值 HOT 4
- Performance issue of Snowflake HOT 1
- org.dromara.hutool.http.HttpUtil#get(java.lang.String) 请求无法成功 HOT 1
- hutool-cache key有效期的使用方式 HOT 1
- 希望能增加一个经纬度处理的工具 HOT 2
- DateUtil.format能否支持增加参数Locale 格式化成其他语言 HOT 1
- 关于ListUtil#setOrPadding的安全检查 HOT 2
- BooleanUtil.andOfWrap针对null取与结果与预期不符 HOT 1
- JSONObject.toBean为null问题 HOT 2
- 图片添加文字水印可以支持45度倾斜多行重复文字的效果么 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.