Fastjson 教程
2021-01-20 21:14
标签:code fast 转换 类型 class maps system parse tst 说明:TypeReference用于复杂类型的转换。 Fastjson 教程 标签:code fast 转换 类型 class maps system parse tst 原文地址:https://www.cnblogs.com/feiqiangsheng/p/13303063.html对象转Json字符串
Person p = new Person("费哥", 26);
String jsonString = JSON.toJSONString(p);
System.out.println(jsonString);
Json字符串转对象(一)
Person p = new Person("费哥", 26);
String jsonString = JSON.toJSONString(p);
JSONObject jsonObject = JSON.parseObject(jsonString);
System.out.println(jsonObject.getString("name"));
Json字符串转对象(二)
Person p = new Person("费哥", 26);
String jsonString = JSON.toJSONString(p);
Person person = JSON.parseObject(jsonString, Person.class);
List转Json字符串
Person p1 = new Person("费哥", 26);
Person p2 = new Person("费哥2", 26);
List
Json字符串转List
Person p1 = new Person("费哥", 26);
Person p2 = new Person("费哥2", 26);
List
Json字符串转JSONArray
Person p1 = new Person("费哥", 26);
Person p2 = new Person("费哥2", 26);
List
Json字符串转List
String objString = "[{‘zhangsan‘:{‘name‘:‘zhangsan‘,‘age‘:12},‘lishi‘:{‘name‘:‘lishi‘,‘age‘:12}}]";
List