Json返回结果为null属性不显示解决
2021-05-12 03:29
标签:turn org converter spring condition app build ann ret 0.0 Json返回结果为null属性不显示解决 标签:turn org converter spring condition app build ann ret 原文地址:https://www.cnblogs.com/-flq/p/12012589.htmlimport java.io.IOException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
@Configuration
public class JacksonConfig {
@Bean
@Primary
@ConditionalOnMissingBean(ObjectMapper.class)
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer
下一篇:遍历json的几种方式。
文章标题:Json返回结果为null属性不显示解决
文章链接:http://soscw.com/index.php/essay/84514.html