use of com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4 in project spring-cloud by Rogge666.
the class WebMvcConfigurer method configureMessageConverters.
// 使用阿里 FastJson 作为JSON MessageConverter
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4();
FastJsonConfig config = new FastJsonConfig();
// 保留空的字段
config.setSerializerFeatures(// 保留空的字段
SerializerFeature.WriteMapNullValue, // String null -> ""
SerializerFeature.WriteNullStringAsEmpty, // 使枚举返回ordinal
SerializerFeature.WriteEnumUsingToString, // Number null -> 0
SerializerFeature.WriteNullNumberAsZero);
converter.setFastJsonConfig(config);
converter.setDefaultCharset(Charset.forName("UTF-8"));
converters.add(converter);
}
use of com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4 in project new-cloud by xie-summer.
the class WebMvcConfigurer method configureMessageConverters.
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4();
FastJsonConfig config = new FastJsonConfig();
config.setSerializerFeatures(// 保留空的字段
SerializerFeature.WriteMapNullValue, // String null -> ""
SerializerFeature.WriteNullStringAsEmpty, // Number null -> 0
SerializerFeature.WriteNullNumberAsZero);
converter.setFastJsonConfig(config);
converter.setDefaultCharset(Charset.forName("UTF-8"));
converters.add(converter);
}
Aggregations