fastjson参考
参考:http://doc.yaojieyun.com/www.runoob.com/w3cnote/java-json-instro.html
参考: http://doc.yaojieyun.com/www.runoob.com/w3cnote/fastjson-intro.html
序列化:JSON.toJSONString(person)将Java 对象转换为 JSON 字符串;
反序列化:JSON.parseObject() 将 JSON 字符串转换为 Java 对象;
@JSONField(name=“AGE”, serialize=false)
@JSONField(name = “DATE OF BIRTH”, deserialize=false)
Object转为其他类型
Map<String,Object> map = JsonUtils.parseObject(s, Map.class);
String accessToken = (String) map.get("access_token");
// Integer 转化为 Long
Long expiresIn = Long.valueOf(map.get("expires_in").toString());
fastjson和jackson gson和fastjson
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.28</version>
</dependency>
JSONObject jsonObject = JSONObject.parseObject(s);
String accessToken = jsonObject.getString("access_token");
long expiresIn = jsonObject.getLongValue("expires_in");