JSON转换String、List

导包:

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);
原文地址:https://www.cnblogs.com/supiaopiao/p/13050349.html