alibaba / fastjson2

🚄 FASTJSON2 is a Java JSON library with excellent performance.
Apache License 2.0
3.74k stars 484 forks source link

1.2.83 升级 2.0.40 值丢失?[BUG] #1840

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.40 输出 {}
}
}
xiangyunup commented 1 year ago

@JsonIgnore 这个注解是jackson的,很多地方需要区分忽略。是否可以按照fastJSON1.*的时候处理分式,区分开了?现在好像是有这个注解的,fastjson2 也会忽略属性了。

shuohao commented 8 months ago

+1

lihangfu commented 7 months ago

+1