java 官方
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220320</version>
</dependency>
- code
JSONObject jsonObject = new JSONObject();
jsonObject.put("secretKey", secretKey);
jsonObject.put("appKey", appKey);
System.out.println("JSON JAVA :" + jsonObject + "\n");
google gson
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
- code
Gson gson = new Gson();
System.out.println("GSON GOOGLE :" + gson.toJson(enInforMap) + "\n");
alibaba fastjson
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.67_noneautotype2</version>
</dependency>
- code
com.alibaba.fastjson.JSONObject fastJsonObject = new com.alibaba.fastjson.JSONObject();
fastJsonObject.put("secretKey", secretKey);
fastJsonObject.put("appKey", appKey);
System.out.println("FASTJSON ALIBABA :" + fastJsonObject + "\n");
jackjson FasterXML
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.7.1</version>
</dependency>
- code
ObjectMapper objectMapper = new ObjectMapper();
System.out.println("JACKSON FasterXML :" + objectMapper.writeValueAsString(enInforMap) + "\n");
标签:code,java,System,secretKey,json,格式,fastJsonObject,com,gson
From: https://www.cnblogs.com/guanchaoguo/p/17325160.html