当前位置:网站首页>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
边栏推荐
- 启牛的涨乐财付通如何?安全靠谱吗
- Vscode / * * generate function comments
- win10安装cuda的操作步骤(不断完美中)
- BILSTM和CRF的那些事
- How to judge whether you are suitable for software testing
- A simple and easy-to-use graph visualization tool developed recently
- 智能对话01-redis的安装
- 【工作小技巧】刚入职的软件测试工程师怎么快速上手新岗位
- Distributed remote management of distribution room environment
- Is it safe for a securities company to open an account with the lowest handling fee among the top ten
猜你喜欢
![[compilation principle] overview](/img/af/246750beb72842e83a19e42270c09e.png)
[compilation principle] overview

Computing architecture of microblog comments

Recursion and divide and conquer

【工作小技巧】刚入职的软件测试工程师怎么快速上手新岗位

Wechat applet reports an error: request:fail URL not in domain list
Qinheng ch583 USB custom hid debugging record

解决nvprof 报错ERR_NVGPUCTRPERM - The user does not have permission to profile on the target device.

Kotlin of Android cultivation manual - several ways to write a custom view

使用DiskGenius拓展系统盘C盘的容量

Unity technical manual - interference / noise sub module
随机推荐
Introduction to microservices
华为云GaussDB(for Redis)揭秘第19期:GaussDB(for Redis)全面对比Codis
Is it convenient to open a stock account? Is online account opening safe?
conda安装的py3.6和py3.7
A simple and easy-to-use graph visualization tool developed recently
Matlab中图形对象属性gca使用
Swagger实现后台接口自动化文档
Expressing integers by the sum of consecutive natural numbers
为什么在变频器场合需要安科瑞的电力有源滤波器?
Is the actual account opening complicated? Is online account opening safe?
观察者模式之通用消息发布与订阅
微信小程序报错:request:fail url not in domain list
Mobile heterogeneous computing technology - GPU OpenCL programming (basic)
158_模型_Power BI 使用 DAX + SVG 打通制作商业图表几乎所有可能
Swagger implements background interface automation document
证券公司排名前十手续费最低 办理开户安全吗
篇7:CLion中没有代码提示,,,
智能对话01-redis的安装
Virtual machine class loading mechanism
Redis趋势—NVM内存