标签:from 转化 iba googl on() com ssi end object
依赖:
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
方法:
Map map = new HashMap();
map.put("sex", "男");
JSONObject jsonObject = JSONObject.fromObject(map);
//将json对象转化为json字符串
String result = jsonObject.toString();
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.41</version>
</dependency>
方法:
Map map = new HashMap();
map.put("sex", "男");
String result = JSONUtils.toJSONString(map);
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
方法:
Map map = new HashMap();
map.put("sex", "男");
String result = new Gson().toJson(param).toString();
标签:from 转化 iba googl on() com ssi end object
原文地址:https://www.cnblogs.com/javalinux/p/14330912.html