JSON
本质就是一个字符串
JSON
串的键要求必须使用双引号括起来,而值根据要表示的类型确定
导入依赖
<!-- https://mvnrepository.com/artifact/taglibs/standard -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
java和json之间的转换
//将java转化为json字符串
User user = new User(1, "zhangsan", "123");
String jsonString = JSON.toJSONString(user);
System.out.println(jsonString);
//将json字符串转为java
User u = JSON.parseObject(jsonString, User.class);
System.out.println(u);
标签:11,jsonString,java,json,2024,JSON,User,字符串
From: https://www.cnblogs.com/XYu1230/p/18521746