|
@@ -1,9 +1,11 @@
|
|
package com.xiesx.fastboot.core.fastjson.cfg;
|
|
package com.xiesx.fastboot.core.fastjson.cfg;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.math.BigInteger;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
|
|
+import com.alibaba.fastjson.serializer.SerializeConfig;
|
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
|
+import com.alibaba.fastjson.serializer.ToStringSerializer;
|
|
|
|
+import com.alibaba.fastjson.support.config.FastJsonConfig;
|
|
|
|
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
|
|
+import com.xiesx.fastboot.core.fastjson.cfg.FastJsonProperties;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
@@ -11,11 +13,8 @@ import org.springframework.http.MediaType;
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
-import com.alibaba.fastjson.serializer.SerializeConfig;
|
|
|
|
-import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
|
-import com.alibaba.fastjson.serializer.ToStringSerializer;
|
|
|
|
-import com.alibaba.fastjson.support.config.FastJsonConfig;
|
|
|
|
-import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
|
|
|
|
+import java.math.BigInteger;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Configuration
|
|
@Configuration
|
|
@EnableConfigurationProperties(FastJsonProperties.class)
|
|
@EnableConfigurationProperties(FastJsonProperties.class)
|
|
@@ -25,15 +24,15 @@ public class FastJsonCfg implements WebMvcConfigurer {
|
|
// 字符类型字段如果为null,输出为"",而不是null
|
|
// 字符类型字段如果为null,输出为"",而不是null
|
|
SerializerFeature.WriteNullStringAsEmpty,
|
|
SerializerFeature.WriteNullStringAsEmpty,
|
|
// 数值字段如果为null,输出为0,而不是null
|
|
// 数值字段如果为null,输出为0,而不是null
|
|
- SerializerFeature.WriteNullNumberAsZero,
|
|
|
|
|
|
+// SerializerFeature.WriteNullNumberAsZero,
|
|
// Boolean字段如果为null,输出为false,而不是null
|
|
// Boolean字段如果为null,输出为false,而不是null
|
|
- SerializerFeature.WriteNullBooleanAsFalse,
|
|
|
|
|
|
+// SerializerFeature.WriteNullBooleanAsFalse,
|
|
// 枚举类型用ToString输出为
|
|
// 枚举类型用ToString输出为
|
|
- SerializerFeature.WriteEnumUsingToString,
|
|
|
|
|
|
+// SerializerFeature.WriteEnumUsingToString,
|
|
// 是否输出值为null的字段
|
|
// 是否输出值为null的字段
|
|
- // SerializerFeature.WriteMapNullValue,
|
|
|
|
|
|
+ SerializerFeature.WriteMapNullValue,
|
|
// list字段如果为null,输出为[],而不是null
|
|
// list字段如果为null,输出为[],而不是null
|
|
- // SerializerFeature.WriteNullListAsEmpty,
|
|
|
|
|
|
+ SerializerFeature.WriteNullListAsEmpty,
|
|
// 输出格式后的日期
|
|
// 输出格式后的日期
|
|
SerializerFeature.WriteDateUseDateFormat,
|
|
SerializerFeature.WriteDateUseDateFormat,
|
|
// 禁用循环引用
|
|
// 禁用循环引用
|