配置代码
// 设置输出时包含属性的风格
this.findAndRegisterModules();
this.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
// 允许单引号、允许不带引号的字段名称
this.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
this.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
this.configure(MapperFeature.USE_STD_BEAN_NAMING, true)
// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// 空值处理为空串
this.serializerProvider.setNullValueSerializer(object : JsonSerializer<Any>() {
@Throws(IOException::class, JsonProcessingException::class)
override fun serialize(value: Any, jgen: JsonGenerator,
provider: SerializerProvider) {
jgen.writeString("")
}
})
// 设置时区
this.setTimeZone(TimeZone.getDefault())//getTimeZone("GMT+8:00") // 设置输出时包含属性的风格
this.findAndR