liurunyu
2023-11-28 de747065f733ba1edb0345be57412604661cca0d
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/fastjson/FastJsonConfig.java
@@ -6,14 +6,17 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
 * 必须实现WebMvcConfigurer否则不启作用,即Controller转json时不用fastjson
 */
@Configuration
public class FastJsonConfig  {
public class FastJsonConfig implements WebMvcConfigurer {
    /**
     * 配置fastjson输出格式
     **/
@@ -29,12 +32,12 @@
                JSONWriter.Feature.WriteMapNullValue,
                //输出null的boolean 为 false
                JSONWriter.Feature.WriteNullBooleanAsFalse,
                //把Long型输出为String
                //把Long型输出为String,在pojo的属性中个性设置
                //JSONWriter.Feature.WriteLongAsString,
                //输出null的list 为 []
                JSONWriter.Feature.WriteNullListAsEmpty,
                //输出null的number 为 0
                JSONWriter.Feature.WriteNullNumberAsZero,
                //JSONWriter.Feature.WriteNullNumberAsZero,
                //输出null字符串 为 ""
                JSONWriter.Feature.WriteNullStringAsEmpty,
                //对map进行排序