当前位置:网站首页>New typereference usage fastjson[easy to understand]
New typereference usage fastjson[easy to understand]
2022-06-25 18:05:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
new TypeReference usage fastjson
Personally, there are many scenes involved , Most of the information I get by calling other people's interfaces , Then map the case of the entity . When you don't know this method, every time you get a string and want to map an object , Just jsonobject All kinds of transformations , I don't want to read the code I wrote , Don't talk much about code !!!
// This new typeReference The imported package is package com.alibaba.fastjson;
// It also has a bag package com.fasterxml.jackson.core.type;
/** * This is a conversion list Example , To object or map It's about the same **/
String provinces = readJsonFile(".//areaCode//provinces.json");
List<NationalCityCode> provinceList = jsonObject.parseObject(provinces, new TypeReference<List<NationalCityCode>>() {
});
for (NationalCityCode province : provinceList) {
redisTemplate.opsForValue().set(province.getCode(), province.getName());
}/** * Turn to object **/
String provinces = readJsonFile(".//areaCode//provinces.json");
NationalCityCode province = jsonObject.parseObject(provinces, new TypeReference<NationalCityCode>() {
});
for (NationalCityCode province : provinceList) {
redisTemplate.opsForValue().set(province.getCode(), province.getName());
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151110.html Link to the original text :https://javaforall.cn
边栏推荐
- Operating steps for installing CUDA in win10 (continuous improvement)
- Vscode / * * generate function comments
- 深入理解ELF文件
- MySQL mysql-8.0.19-winx64 installation and Navicat connection
- Getting started with kotlin (20) several common dialog boxes
- 158_模型_Power BI 使用 DAX + SVG 打通制作商业图表几乎所有可能
- How to judge whether you are suitable for software testing
- Uncover ges super large scale graph computing engine hyg: Graph Segmentation
- 力扣每日一题-第27天-561.数组拆分Ⅰ
- ASP.NET超市便利店在线购物商城源码,针对周边配送系统
猜你喜欢
随机推荐
近来开发的一款简单易用的图可视化工具
[matlab] curve fitting
微服务介绍
SDN system method | 10 The future of SDN
[machine learning] case study of college entrance examination prediction based on multiple time series
观察者模式之通用消息发布与订阅
Time series analysis of data mining [easy to understand]
VSCode /**生成函数注释
How about qiniu's Zhangle TenPay? Is it safe
RuntimeError: Trying to backward through the graph a second time (or directly access saved variable
SDN系统方法 | 9. 接入网
Bert's summary of me
MVDR beam MATLAB, MVDR beam forming matlab[easy to understand]
解决nvprof 报错ERR_NVGPUCTRPERM - The user does not have permission to profile on the target device.
Use of jupyter
【工作小技巧】刚入职的软件测试工程师怎么快速上手新岗位
Expressing integers by the sum of consecutive natural numbers
利用Qt制作美化登录界面框
Part 5:vs2017 build qt5.9.9 development environment
How to open a stock account? Is it safe to open a securities account








![[compilation principle] overview](/img/af/246750beb72842e83a19e42270c09e.png)
