-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix jsonb WriteNulls, for issue #2234
- Loading branch information
Showing
6 changed files
with
142 additions
and
28 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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
core/src/test/java/com/alibaba/fastjson2/issues_2200/Issue2234.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,34 @@ | ||
package com.alibaba.fastjson2.issues_2200; | ||
|
||
import com.alibaba.fastjson2.JSONB; | ||
import com.alibaba.fastjson2.JSONWriter; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class Issue2234 { | ||
@Test | ||
public void test() { | ||
Bean bean = new Bean(); | ||
bean.f0 = null; | ||
bean.f1 = null; | ||
bean.f2 = null; | ||
bean.f3 = null; | ||
bean.f4 = null; | ||
bean.f5 = null; | ||
bean.f6 = null; | ||
bean.f7 = null; | ||
|
||
byte[] jsonb = JSONB.toBytes(bean, JSONWriter.Feature.WriteNulls, JSONWriter.Feature.FieldBased); | ||
System.out.println(JSONB.toJSONString(jsonb)); | ||
} | ||
|
||
static class Bean { | ||
private Boolean f0 = true; | ||
private Byte f1 = 101; | ||
private Short f2 = 101; | ||
private Integer f3 = 102; | ||
private Long f4 = 103L; | ||
private Float f5 = 103F; | ||
private Double f6 = 103d; | ||
private Character f7 = 'a'; | ||
} | ||
} |