Map 和 Json 互转

Json 转 Map<String,String>

String query = "{tableName:\"iov_biz_car_info\",selectCol:\"framenum,carId,carBrandId\",where:\"cbm_mag_company_id=50060\"}";
JSONObject queryO = JSONObject.parseObject(query);
Map<String, String> strParams = Maps.transformValues(queryO, Functions.toStringFunction());
System.out.println(strParams.toString());

  

Map 转 Json

 导入Gson.jar

new com.google.gson.Gson.Gson().toJson(strParams)

  

posted @ 2019-05-31 13:32  蔡徐坤1987  阅读(263)  评论(0编辑  收藏  举报