第一种
import com.google.gson.Gson;
import com.facebook.presto.jdbc.internal.guava.reflect.TypeToken;
Object propertys = map.get(“property”);
List property = new Gson().fromJson(new Gson().toJson(propertys), new TypeToken<List>(){}.getType());
如果有日期类型 这种的就会出错
第二种 转对象
JSONObject json = JSONObject.fromObject(map.get(“model”));
Object obj = JSONObject.toBean(json, TableEntity.class);
JSONObject objJson = JSONObject.fromObject(obj);
ModelManages manages = (ModelManages) JSONObject.toBean(objJson, ModelManages.class);
转List
import net.sf.json.JSONObject;
List<TableEntityVo> tableEntities = net.sf.json.JSONArray.toList(net.sf.json.JSONArray.fromObject(tableEntity), TableEntityVo.class);
集合对象转字符串
List<MoveDto.Activity.Rule> ruler = moveDto.getActivity().getRuler();
if (!ruler.isEmpty()) {
Gson gson = new Gson();
String s = gson.toJson(ruler);
activityContent.setRuler(s);
}