-
Notifications
You must be signed in to change notification settings - Fork 547
Closed
Labels
Milestone
Description
问题描述
Fastjson2对布尔值序列化的问题
环境信息
Fastjson 2.0.51
重现步骤
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Builder;
import lombok.Data;
import org.junit.Test
public class FastJSONTest {
@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(JSONObject.toJSONString(student));
}
}期待的正确结果
输出的结果可以发现isJudge字段变成了judge,这个是和1版本不一致的,我试过1.2.83是可以转成is_judge的。使用@DaTa会为isJudge字段生成一个getter,就叫isJudge(),方法和字段同名,可能这里就是导致判断逻辑不一致的原因。我想请问这里是bug还是预期之内?
相关日志输出
{"judge":true}
附加信息
无