当前位置:网站首页>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
边栏推荐
猜你喜欢
![[daily record] - bug encountered during BigDecimal Division](/img/76/efb117986ac319987d4453bf00bec9.png)
[daily record] - bug encountered during BigDecimal Division

ASP. Net supermarket convenience store online shopping mall source code, for the surrounding distribution system
沁恒CH583 USB 自定义HID调试记录

Introduction to microservices

lock

有关均衡----简易版瓶颈模型

深入理解ELF文件

Acy100 oil fume concentration online monitor for kitchen oil fume emission in catering industry

Recursion and divide and conquer

观察者模式之通用消息发布与订阅
随机推荐
智能体白皮书 - 共建智能体,共创全场景智慧 | 云享书库NO.21推荐
证券公司排名前十手续费最低 办理开户安全吗
conda安装的py3.6和py3.7
微服务介绍
Is the actual account opening complicated? Is online account opening safe?
Why do we need ankeri's active power filter in frequency converter occasions?
什么是算子?
What is an operator?
Three traversal methods of binary tree (recursive + non recursive) complete code
Expressing integers by the sum of consecutive natural numbers
Uncover ges super large scale graph computing engine hyg: Graph Segmentation
CONDA modifying a mirror source
解决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
container of()函数简介
Sentinel哨兵机制
VSCode /**生成函数注释
SQL Server实时备份库要求
使用DiskGenius拓展系統盤C盤的容量
[compilation principle] lexical analysis