1、字符串转JSONArray
JSONArray jsonArray = JSONArray.parseArray(versions);
2、json转实体类
RetailEntity tb = JSONObject.toJavaObject(jsonObject, RetailEntity.class);
3、实体类转json
JSONObject json = (JSONObject) JSONObject.toJSON(corn);
4、集合转json
JSONArray json = (JSONArray) JSONObject.toJSON(list);
5 实体转为map
Map paramsMap = JSON.parseObject(JSON.toJSONString(personModel), Map.class);
5 jsonArray转为list
List dataArr = JSONArray.parseArray(result,InsBill.class);
6 json转为map
Map params = JSONObject.parseObject(obj.toJSONString(), new TypeReference>(){});
7 map转为json字符串
String paramJson = JSONObject.toJSONString(param));
8、字符串转json
JSONObject parseObject = JSONObject.parseObject(object.toString());
9 map转为对象
JSON.parseObject(JSON.toJSONString(map), ProjInfo.class);
空值也全部转换
JSONObject.toJSONString(reqVo, SerializerFeature.WRITE_MAP_NULL_FEATURES, SerializerFeature.QuoteFieldNames)