1、String 转 bean
String addition = ...;
CoffeeFormula formula = JSON.parseObject(addition, new TypeReference<CoffeeFormula>() {});
2. String转JSONObject
JSONObject obj=JSON.parseObject(addition);
3.bean 转JSONObject
//为null的属性不转换
JSONObject jo = (JSONObject) JSONObject.toJSON(user);
4.JSONObject 转bean
DeviceVersion dVersion = JSON.toJavaObject(contentJsonObject, DeviceVersion.class);
5.fastjson List转JSONArray
List<T> list = new ArrayList<T>();
JSONArray array= JSONArray.parseArray(JSON.toJSONString(list));
6.fastjson JSONArray转List
JSONArray array = new JSONArray();
List<EventColAttr> list = JSONObject.parseArray(array.toJSONString(), EventColAttr.class);
7.fastjson 字符串转List
String str = "";
List<T> list = JSONObject.parseArray(str,T.class);