Skip to content

Commit 9a4036c

Browse files
committed
exclude jackson to avoid some mistakes
1 parent b4667ff commit 9a4036c

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
<dependency>
3232
<groupId>org.springframework.boot</groupId>
3333
<artifactId>spring-boot-starter-web</artifactId>
34+
<exclusions>
35+
<exclusion>
36+
<groupId>com.fasterxml.jackson.core</groupId>
37+
<artifactId>jackson-databind</artifactId>
38+
</exclusion>
39+
</exclusions>
3440
</dependency>
3541
<dependency>
3642
<groupId>org.springframework.boot</groupId>
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
package com.github.binarywang.demo.wechat.utils;
22

3-
import com.fasterxml.jackson.annotation.JsonInclude.Include;
4-
import com.fasterxml.jackson.core.JsonProcessingException;
5-
import com.fasterxml.jackson.databind.ObjectMapper;
6-
import com.fasterxml.jackson.databind.SerializationFeature;
3+
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
74

85
/**
96
* @author Binary Wang(https://github.com/binarywang)
107
*/
118
public class JsonUtils {
12-
private static final ObjectMapper JSON = new ObjectMapper();
13-
14-
static {
15-
JSON.setSerializationInclusion(Include.NON_NULL);
16-
JSON.configure(SerializationFeature.INDENT_OUTPUT, Boolean.TRUE);
17-
}
18-
199
public static String toJson(Object obj) {
20-
try {
21-
return JSON.writeValueAsString(obj);
22-
} catch (JsonProcessingException e) {
23-
e.printStackTrace();
24-
}
25-
26-
return null;
10+
return WxMpGsonBuilder.create().toJson(obj);
2711
}
2812
}

0 commit comments

Comments
 (0)