alibaba / alibaba/fastjson2

[BUG] valueFilter 返回null , 被序列化了

Open
#2,822 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 问题描述
我在springboot中 使用了FastJsonHttpMessageConverter

我自定义了一个valuefilter 根据,业务场景返回修改后的值 或者 不返回

问题: 当我valuefilter 返回null的时候, 最终序列化后的字符串里 含有 "xxx":null
期待的是,和普通情况一样,null字段序列化的时候不要写入

当然我可以结合PropertyFilter , 来处理不返回的情况
但是这里 valueFilter的处理 感觉有问题, 不知道算bug 还是故意这么设计的,

既然默认字段null 是不序列化的 , valueFilter 这里也应该使用相同的规则

Contributor guide

Open the contributing guide

Research direction

Start with FastJsonHttpMessageConverter and the valueFilter behavior described in the issue, then compare it with default null-field serialization and the suggested PropertyFilter path. Done means a valueFilter returning null follows the expected null-field omission rule, with the behavior verified against the existing serialization coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.