String、Json、List相互转换

  • Post author:
  • Post category:其他


 
 
导包:
 
import org.json.JSONObject;
 
1.对象转string
 
String strign = JSONObject.toJSONString(T);
 
 
2.string转对象
 
T t = JSONObject.parseObject(pojo, T.tclass);
 
 
3.Lits转String
 
String jsons = JSON.toJSONString(tList);
 
 
4.String 转list
 
List<T> list = JSONArray.parseArray(string, T.class);
 
 
5.String转json
 
JSONObject jsonObject = JSON.parseObject(string);