字符串转jsonObject
l_jsonObject = JSON.parseObject(String);
获取jsonObject中的集合
l_data = l_jsonObject.getJSONObject("Token");
l_data = l_jsonObject.getJSONOArray("Token");
获取jsonObject中的单个属性
StationNo = l_jsonObject.getString("StationNo");
实体类转json
String oberatorss = JSON.toJSONString(operator);
String l_first = oberatorss.replace("[", "");
String l_last = l_first.replace("]", "");
json转实体
YDBuildRet ydBuildRet = JSON.parseObject(l_BuildRetJsonObject.toJSONString(),
new TypeReference<YDBuildRet>() {
});
json字符串转map
Map<String,String> value = (Map<String, String>) JSON.parse(InfoMaster.toString());
数组转json
ArrayList<?> l_Mem_Stations = _mem_StationMapper.getDataSetType();
JSONArray StationJSONArray = (JSONArray) JSONArray.toJSON(l_Mem_Stations);
for (int i = 0; i < StationJSONArray.size(); i++) {
JSONObject job = StationJSONArray.getJSONObject(i);
job.get("StationType");
job.get("MasterStation");
}