map转换成JSON的3种方式
1. alibaba
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.41</version> </dependency>
JSONUtils.toJSONString(requestMap);
2. json-lib
<dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.5</version> </dependency>
JSONObject jsonObject = JSONObject.fromObject(map);
String result = jsonObject.toString();
3. google
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.3.1</version>
</dependency>
new Gson().toJson(param);