fastjson2 icon indicating copy to clipboard operation
fastjson2 copied to clipboard

1.2.83 升级 2.0.40 值丢失?[BUG]

Open xiangyunup opened this issue 1 year ago • 3 comments

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 avatar Sep 07 '23 10:09 xiangyunup

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

xiangyunup avatar Oct 14 '23 06:10 xiangyunup

+1

shuohao avatar Feb 19 '24 09:02 shuohao

+1

lihangfu avatar Mar 11 '24 09:03 lihangfu