We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在部分字段上使用@JSONField(serializeFeatures = JSONWriter.Feature.WriteNulls)注解,序列化时无法正常序列化null值。
@JSONField(serializeFeatures = JSONWriter.Feature.WriteNulls)
代码如下
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONWriter; import com.alibaba.fastjson2.annotation.JSONField; import lombok.Data; @Data public class C { @JSONField(serializeFeatures = JSONWriter.Feature.WriteNulls) private Long l; @JSONField(serializeFeatures = JSONWriter.Feature.WriteNulls) private Double d; @JSONField(serializeFeatures = JSONWriter.Feature.WriteNulls) private Integer i; @JSONField(serializeFeatures = JSONWriter.Feature.WriteNulls) private String s; public static void main(String[] args) { System.out.println(JSON.toJSONString(new C())); } }
输出结果
{"i":null,"s":null}
{"l":null,"d":null,"i":null,"s":null}
无
The text was updated successfully, but these errors were encountered:
fix prefer FiledWriter.features to JSONWriter.context.features when F…
3bda413
…iledWriter.features is not among (0, JSONWriter.Feature.FieldBased.mask, FieldInfo.FIELD_MASK), for issue #2952
support Clickhouse UnsignedLong, for issue #2952
45b54ec
fix write double field annotation writeNulls not work, for issue #2952
89f2f2e
https://github.com/alibaba/fastjson2/releases/tag/2.0.53 问题已修复,请用新版本
Sorry, something went wrong.
No branches or pull requests
问题描述
在部分字段上使用
@JSONField(serializeFeatures = JSONWriter.Feature.WriteNulls)
注解,序列化时无法正常序列化null值。环境信息
重现步骤
代码如下
输出结果
期待的正确结果
相关日志输出
无
附加信息
无
The text was updated successfully, but these errors were encountered: