fastjson2
fastjson2 copied to clipboard
1.2.83 升级 2.0.40 值丢失?[BUG]
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 输出 {}
}
}
@JsonIgnore 这个注解是jackson的,很多地方需要区分忽略。是否可以按照fastJSON1.*的时候处理分式,区分开了?现在好像是有这个注解的,fastjson2 也会忽略属性了。
+1
+1