alibaba / alibaba/fastjson2

[BUG]JSON.toJSONString配合PropertyPreExcludeFilter后null值的Double会被序列化

Open
#3,865 6 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

### 问题描述
JSON.toJSONString配合PropertyPreExcludeFilter一起使用在序列化时Double是null也会被序列化到JSON

### 环境信息
*请填写以下信息:*

- JDK信息: [e.g.:Openjdk 11.0.19]
- 版本信息:[e.g.:Fastjson2 2.0.58]

### 重现步骤
*如何操作可以重现该问题:*

```java
PropertyPreExcludeFilter PROPERTY_PRE_EXCLUDE_FILTER = new PropertyPreExcludeFilter().addExcludes("id","suWorkRecordId");
JSON.toJSONString(result,PROPERTY_PRE_EXCLUDE_FILTER);
```

### 期待的正确结果
null值的double不会被序列化

#### 附加信息
- 暂时发现有Double
- Integer值null会被正确排除
- 直接使用JSON.toJSONString(result)可以正确排除Double

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by running the provided PropertyPreExcludeFilter example with a result containing a null Double, then compare it with direct JSON.toJSONString(result) serialization; done means null Double values are excluded in both cases while the named properties remain excluded.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.