当前位置:网站首页>JSON,字符串,map之间的互转
JSON,字符串,map之间的互转
2022-06-22 05:11:00 【a good idea】
1.对象与字符串之间的互转
将对象转换成为字符串
String str = JSON.toJSONString(infoDo);
字符串转换成为对象
InfoDo infoDo = JSON.parseObject(strInfoDo, InfoDo.class);2.对象集合与字符串之间的互转
将对象集合转换成为字符串
String users = JSON.toJSONString(users);
将字符串转换成为对象集合
List<User> userList = JSON.parseArray(userStr, User.class); 3.字符串互转JSONObject
String 转 Json对象
JSONObject jsonObject = JSONObject.parseObject(jsonString);
json对象转string
JSONObject jsonObject = JSONObject.parseObject(str);//json对象转字符串
String jsonString = jsonObject.toJSONString();4.map与字符串之间互转
//字符串转map
JSONObject jsonObject = JSONObject.parseObject(str);
Map<String,Object> map = (Map<String,Object>)jsonObject;// //json对象转Map
//map转字符串
String jsonString = JSON.toJSONString(map);5.Map 转 Json对象
//map转json对象
Map<String,Object> map = new HashMap<>();
map.put("age", 24);
map.put("name", "cool_summer_moon");
JSONObject json = new JSONObject(map);
//json对象转Map
Map<String,Object> map = (Map<String,Object>)jsonObject; 边栏推荐
- [scientific research notes] about using the downsampling multiple of openslide cut
- 在Vs Code中搭建JSP开发环境
- 89---狄拉克 delta 函数
- DeformConv
- mysql day02课堂笔记
- [chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)
- [fault diagnosis] CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace B
- 2022 welder (primary) new version test questions and welder (primary) free test questions
- The application of RPC technology and its framework sekiro in crawler reverse, encrypting data is a shuttle!
- In 2022, the super intern plans to make a breakthrough in the offer of it famous enterprises, and the nine high salary skills help the dream of famous enterprises
猜你喜欢

Idea创建方法时,使用注解提示方法参数(param)、返回值(return)、方法作用(Description)
![[chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)](/img/9b/6ad704959a77abf9cb28fdd33b81b5.png)
[chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)

使用matplotlib实现GUI交互效果

Build JSP development environment in vs Code

Software architecture and pattern: structure, component and relationship

How much is London gold

Daemon flow

Virtual address space
![[fault diagnosis] stitch Py script failure](/img/5c/e5df21674b5d0677484b49a608f8ae.png)
[fault diagnosis] stitch Py script failure

Sort ten integers using selection
随机推荐
DTS migration script Oracle
Idea创建方法时,使用注解提示方法参数(param)、返回值(return)、方法作用(Description)
Flink deployment mode (I) - standalone and Application
Concurrent programming - thread pool
Graph calculation on nlive:nepal's graph calculation practice
Use keytool to access the JKS file get SSL certificate
使用matplotlib实现GUI交互效果
不允许方法被重写的方式包括哪些?
C语言数据类型转换规则(隐式转换+显式转换)
Please, use three JS make 2D pictures have 3D effect cool, OK
Storage mode and lifetime of C language variables
mysql day03课堂笔记
In 2022, the super intern plans to make a breakthrough in the offer of it famous enterprises, and the nine high salary skills help the dream of famous enterprises
非递归打印斐波那契数列
招贤纳士-第23期
Sort ten integers using selection
NHibernate method for viewing generated SQL statements
C语言字符串的一些使用注意事项
Go learning (I. Basic Grammar)
这是一个图片