tags: Java
/**
* Empty string back when the physical class sequence-field is NULL
*/
@Configuration
public class JacksonConfig {
@Bean
@Primary
@ConditionalOnMissingBean(ObjectMapper.class)
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
SerializerProvider serializerProvider = objectMapper.getSerializerProvider();
serializerProvider.setNullValueSerializer(new JsonSerializer<Object>() {
@Override
public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
jsonGenerator.writeString("");
}
});
return objectMapper;
}
}
Specify non-persistent specific fields...
SpringBoot does not return Null field methods Add in the physical class @JsonInclude(JsonInclude.Include.NON_NULL) Example:...
I wanted to summarize this article very early, and today there is a similar needs, so move it out Foreword: When the back -end is tone with the front end, there is a situation that is like this. Can y...
[Chen wants to work]: Hello Hello, I am Chen, I am very happy that you can read, nickname is hope that you can continue to enter, go to outstate programmer! The blog comes from the project and the que...
content 1, require 2, [negligible] physical classes, interfaces, current effects, expected results Entity class interface Now effect expected result 3, realize Method 1: Application Configuration Meth...
When the Mybatis query uses the MAP return result, the null value field name does not display the problem Just configure in Application.yml...
Project scene: Project scenario: When the field type in the database does not match the Java entity type, mybatis will map the field to the physical attribute Initial description For example, there is...
We write interfaces to do the field must -fect checks and field length control, and front-end access will be converted with entity classes. In this way, the decision field can be determined whether th...
The main function of the Optional class is to deal with null. In the previous program development, to prevent null pointer exceptions in the program, null verification can be added. The party receivin...