-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix write double field annotation writeNulls not work, for issue #2952
- Loading branch information
Showing
2 changed files
with
56 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
core/src/test/java/com/alibaba/fastjson2/issues_2900/Issue2952.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.alibaba.fastjson2.issues_2900; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONWriter; | ||
import com.alibaba.fastjson2.annotation.JSONField; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2952 { | ||
@Test | ||
public void toJsonList() { | ||
assertEquals("{\"d\":null,\"i\":null,\"l\":null,\"s\":null}", JSON.toJSONString(new C())); | ||
} | ||
|
||
@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; | ||
} | ||
} |