pom配置
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.55</version> </dependency>
在项目中引用
import com.alibaba.fastjson.JSONObject;
在项目中调用
//将map集合转化为json
String json = JSONObject.toJSONString(map);
//将json转化为map集合
HashMap<String,Object> map = (HashMap<String,Object>) JSONObject.parseObject(str,Map.class);