zoukankan      html  css  js  c++  java
  • 响应json去除参数值为空的参数-springboot配置

    1.添加jackson相关依赖

    <!--jackson 开始-->
    <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>${jackson.version}</version>
    </dependency>
    <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>${jackson.version}</version>
    </dependency>
    <!--jackson 结束-->

    2.添加如下配置

    /**
    * @Author dinghaifeng(丁海峰)
    * @Date 2018/11/8
    * @Time 17:40
    * @Discription 不显示空参数的配置
    */
    @Configuration
    public class JsonConfig {
    @Bean
    @Primary
    @ConditionalOnMissingBean(ObjectMapper.class)
    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder){
    ObjectMapper objectMapper = builder.createXmlMapper(false).build();
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    return objectMapper;
    }
    }
  • 相关阅读:
    Linux命令——find
    Linux命令——locate
    python模块:datetime
    python模块:json
    python模块:shelve
    python模块:shutil
    python模块:sys
    python:OS模块
    str.index()与str.find()比较
    python模块:re
  • 原文地址:https://www.cnblogs.com/sunshinekevin/p/9930584.html
Copyright © 2011-2022 走看看