使用fastjson 进行jsonObject转实体类对象
fastjson
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
项目地址:https://gitcode.com/gh_mirrors/fastj/fastjson
免费下载资源
·
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.7</version>
</dependency>
首先引入相关jar包,
假设有一个实体类User
public class User{
private int id;
private String name;
}
然后通过fastJson进行类型转换
复制代码
public static void main(String[] args){
String userString = "{"id":1,"name","lz"}";
JSONObject userJson = JSONObject.parseObject(userString);
User user = JSON.toJavaObject(userJson,User.class);
}
GitHub 加速计划 / fastj / fastjson
25.69 K
6.51 K
下载
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
最近提交(Master分支:3 个月前 )
c942c834 - 1 年前
5bc4709b - 1 年前
更多推荐
已为社区贡献2条内容
所有评论(0)