-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix boolean field annotation not work, for issue #2795
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 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
25 changes: 25 additions & 0 deletions
25
core/src/test/java/com/alibaba/fastjson2/issues_2700/Issue2795.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,25 @@ | ||
package com.alibaba.fastjson2.issues_2700; | ||
|
||
import com.alibaba.fastjson.annotation.JSONField; | ||
import com.alibaba.fastjson2.JSONObject; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2795 { | ||
@Builder | ||
@Data | ||
public static class Student { | ||
@JSONField(name = "is_judge") | ||
private boolean isJudge; | ||
} | ||
|
||
@Test | ||
public void testFastJson() { | ||
Student student = Student.builder().isJudge(true).build(); | ||
System.out.println(com.alibaba.fastjson.JSON.toJSONString(student)); | ||
assertEquals("{\"is_judge\":true}", JSONObject.toJSONString(student)); | ||
} | ||
} |