Maven引入
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.37</version>
</dependency>
将json字符串反序列化成对象示例:
HttpInfo httpInfo = JSON.parseObject(info,HttpInfo.class);
JSONObject jsonObject = JSONObject.fromObject(info);
1. 将对象序列化成json字符串
String com.alibaba.fastjson.JSON.toJSONString(Object object)
2. 将json字符串反序列化成对象
<T> Project com.alibaba.fastjson.JSON.parseObject(String text, Class<T> clazz)
3. 将json字符串反序列化成JSON对象
JSONObject com.alibaba.fastjson.JSON.parseObject(String text)