<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.56</version>
</dependency>
public class Test2 {
public static void main(String[] args) {
Map<String,Object> map = new HashMap ();
map.put ("name", "张三");
map.put ("age", 12);
String jsonStirng = JSONObject.toJSONString (map);
System.out.println (jsonStirng);
}
}
public class Test {
public static void main(String[] args) {
String jsonString = "{\n" +
"\t\"name\": \"你好\",\n" +
"\t\"age\": \"13\"\n" +
"}";
JSONObject jsonObject = JSONObject.parseObject (jsonString);
String jsonObjectString = jsonObject.getString ("name");
System.out.println (jsonObjectString);
}
}