Open xiangyunup opened 1 year ago
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Setter;
@Setter public class TestVo implements Serializable {
@JsonIgnore private String test1; @JsonIgnore @JSONField(serialize = false) private String test2; public String getTest1() { if(StringUtil.isNotEmpty(test2)){ return test2; } return test1; } public static void main(String[] args) { TestVo test = new TestVo(); test.setTest2("a"); System.out.println(JSON.toJSONString(test)); // 1.2.83 输出 {"test1":"a"} 2.0.21 输出 {} }
}
https://github.com/alibaba/fastjson2/issues 可以提issue到这里么?
因为一些原因,导致刚看到,已经从新提交。
https://github.com/alibaba/fastjson2/issues/1840#issue-1885607029
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Setter;
@Setter public class TestVo implements Serializable {
}