1.依赖
<!-- fastjson2 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.49</version>
</dependency>
2.使用
2.1 String to javaBean
String text = "...";
User data = JSON.parseObject(text, User.class);
2.2 String to JsonObject
JSONObject data = JSON.parseObject(text);
2.3 JsonObject获取数据
String messageId = obj.getString("messageId");
2.4 JavaBean to String
JSON.toJSONString(addressRes.getData())
标签:Fastjson2,String,text,parseObject,JSON,JsonObject
From: https://www.cnblogs.com/lwx11111/p/18614849