引入fastJson的依赖
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
HashMap<String,String>map = new HashMap<>();
map.put("a","1");
map.put("b","2");
map.put("c","3");
String json = JSON.toJSONString(map);//map转String
JSONObject jsonObject = JSON.parseObject(json);//String转json
//json转map
Map<String, String> jsonMap = JSONObject.toJavaObject(jsonObject, Map.class);
//String转map
Map<String, String> jsonMap1 = JSONObject.parseObject(json, Map.class);