File tree Expand file tree Collapse file tree 2 files changed +8
-18
lines changed
src/main/java/com/github/binarywang/demo/wechat/utils Expand file tree Collapse file tree 2 files changed +8
-18
lines changed Original file line number Diff line number Diff line change 31
31
<dependency >
32
32
<groupId >org.springframework.boot</groupId >
33
33
<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 >
34
40
</dependency >
35
41
<dependency >
36
42
<groupId >org.springframework.boot</groupId >
Original file line number Diff line number Diff line change 1
1
package com .github .binarywang .demo .wechat .utils ;
2
2
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 ;
7
4
8
5
/**
9
6
* @author Binary Wang(https://github.com/binarywang)
10
7
*/
11
8
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
-
19
9
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 );
27
11
}
28
12
}
You can’t perform that action at this time.
0 commit comments