spring boot出入参时间格式设定
1 2
| @JsonFormat(pattern = "yyyy-MM-dd") private Date sendExpressTime;
|
spring boot 出参null转成””
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| @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<Object>() { @Override public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeString(""); } }); return objectMapper; } }
|
自定义key
fastjson的key是根据javabean里面的getter和setter方法来的,key与方法名不致时,属性上面需要标注
@JSONField(name=”SOMETHING”)