当前位置:网站首页>Conversion between JSON, string and map
Conversion between JSON, string and map
2022-06-22 05:16:00 【a good idea】
1. Object to string
Convert objects to strings
String str = JSON.toJSONString(infoDo);
String to object
InfoDo infoDo = JSON.parseObject(strInfoDo, InfoDo.class);2. Object set and string conversion
Convert the collection of objects to strings
String users = JSON.toJSONString(users);
Convert string to object collection
List<User> userList = JSON.parseArray(userStr, User.class); 3. String conversion JSONObject
String turn Json object
JSONObject jsonObject = JSONObject.parseObject(jsonString);
json Object turn string
JSONObject jsonObject = JSONObject.parseObject(str);//json Object to string
String jsonString = jsonObject.toJSONString();4.map And string to string
// String rotation map
JSONObject jsonObject = JSONObject.parseObject(str);
Map<String,Object> map = (Map<String,Object>)jsonObject;// //json Object turn Map
//map Turn the string
String jsonString = JSON.toJSONString(map);5.Map turn Json object
//map turn json object
Map<String,Object> map = new HashMap<>();
map.put("age", 24);
map.put("name", "cool_summer_moon");
JSONObject json = new JSONObject(map);
//json Object turn Map
Map<String,Object> map = (Map<String,Object>)jsonObject; 边栏推荐
- 6. Local - custom filter factory
- How much is London gold
- 冰河十年前的预测如今被阿里实现了,非常震撼
- Analysis of T elevator repair in 2022 and simulation test questions of T elevator repair
- lua笔记
- 2022 a special equipment related management (elevator) examination data and a special equipment related management (elevator) analysis
- What problems will be encountered during the implementation of MES management system
- 8. Gateway request logging
- Storage mode and lifetime of C language variables
- Monorepo silk slide methodology: reference module hot update
猜你喜欢

liunx虚拟机环境使用docker安装oracle数据库,并使用navicat连接

Rétroaction sur la remise des diplômes! Tous les contributeurs de la communauté Apache Doris sont ici pour recevoir des cadeaux!

Accelerate the promotion of industrial Internet, and map out a new blueprint for development

图扑软件2D与2.5D案例合集|智慧园区、数据中心、SMT 生产线...
Please, use three JS make 2D pictures have 3D effect cool, OK
![Reading notes on how MySQL works [updating]](/img/4a/56cff3db0d45e66f51beb490c3ae71.jpg)
Reading notes on how MySQL works [updating]

并发编程——线程池

非递归打印斐波那契数列

It's 2022. Don't you hurry to learn typescript?

Liunx virtual machine environment uses docker to install Oracle database and Navicat to connect
随机推荐
restframework读取和非读取序列处理
DTS迁移秘籍-SQLSERVER篇
不允许方法被重写的方式包括哪些?
非递归打印斐波那契数列
DeformConv
花式优化器整理
Lottie components make animation easier
Software architecture and pattern: structure, component and relationship
Free questions for polymerization process and test papers for polymerization process in 2022
Monorepo丝滑方法论:引用模块热更新
Pytest (12) -allure common features allure attach、allure. step、fixture、environment、categories
[chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)
加快推进工业互联网,图扑“智”绘发展新蓝图
flink部署模式(二)- yarn三种部署模式
Qt保存QTextEdit内存至.txt文件中
Solve the shortage of developers. Maybe it can help you
Detailed explanation of deep learning technology for building an image search engine that can find similar images
CS 611 Game
jedispool工具类
Reconstructing thinking series 2-functions and variables