alibaba / fastjson

FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
https://github.com/alibaba/fastjson2/wiki/fastjson_1_upgrade_cn
Apache License 2.0
25.74k stars 6.5k forks source link

1.2.83 升级 2.0.21 值丢失? #4334

Open xiangyunup opened 1 year ago

xiangyunup commented 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 输出 {}
}

}

wenshao commented 1 year ago

https://github.com/alibaba/fastjson2/issues 可以提issue到这里么?

xiangyunup commented 1 year ago

https://github.com/alibaba/fastjson2/issues 可以提issue到这里么?

因为一些原因,导致刚看到,已经从新提交。

https://github.com/alibaba/fastjson2/issues/1840#issue-1885607029