MCPcopy Create free account
hub / github.com/diyhi/bbs / objectMapper

Method objectMapper

src/main/java/cms/config/JacksonConfig.java:28–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27
28 @Bean
29 @Primary
30 public JsonMapper objectMapper() {
31 // 使用 Jackson 3.x 的 JsonMapper.builder() 构建器
32 SimpleModule customModule = buildCustomModule();
33 final JsonMapper mapper = JsonMapper.builder()
34 // 注册模块
35 .addModule(customModule)
36
37 // 设置日期时间格式
38 .defaultDateFormat(new java.text.SimpleDateFormat(DATE_TIME_FORMAT))
39
40 // 设置时区
41 //.defaultTimeZone(TimeZone.getTimeZone("GMT+8"))
42
43 // JSON转POJO时,若JSON中的某个字段在POJO中未定义,忽略
44 .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
45
46 // 允许出现特殊字符和转义符 (使用 3.x 的 JsonReadFeature)
47 .configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS, true)
48
49
50 .build();
51
52 return mapper;
53 }
54
55
56

Callers

nothing calls this directly

Calls 1

buildCustomModuleMethod · 0.95

Tested by

no test coverage detected