-
Notifications
You must be signed in to change notification settings - Fork 550
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
问题描述
简要描述您碰到的问题。
序列化 map 还是为null
config.setWriterFeatures( JSONWriter.Feature.NullAsDefaultValue)
map返回为null "map": null,
环境信息
请填写以下信息:
springboot 2.6.3
- JDK信息: [e.g.:Openjdk 1.8.0_312]
- 版本信息:[e.g.:Fastjson2 2.0.4]
@Bean
public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {
FastJsonHttpMessageConverter messageConverter = new FastJsonHttpMessageConverter();
FastJsonConfig config = messageConverter.getFastJsonConfig();
config.setReaderFeatures(JSONReader.Feature.FieldBased, JSONReader.Feature.SupportArrayToBean);
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
config.setWriterFeatures(
JSONWriter.Feature.PrettyFormat
, JSONWriter.Feature.NullAsDefaultValue
);
messageConverter.setFastJsonConfig(config);
messageConverter.setDefaultCharset(StandardCharsets.UTF_8);
messageConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
return messageConverter;
}期待的正确结果
对您期望发生的结果进行清晰简洁的描述。
不应该为 "map": {} 的嘛
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working