fastjson icon indicating copy to clipboard operation
fastjson copied to clipboard

升级到1.2.83的不兼容的问题

Open gougouzcm opened this issue 3 years ago • 0 comments

以下的代码 1.2.3版本可以跑,升级到1.2.83 不行。双下划线的 __id 会反序列化id 上。求告知怎么忽略__id

` public class ATest {

public static void main(String[] args) {


    A zcm = new A(100L, "111");

    String s = JSON.toJSONString(zcm);


    System.out.println(s);


    List<A> a1 = JSON.parseArray("[{\"id\":100,\"name\":\"111\"}]", A.class);

    List<A> a2 = JSON.parseArray("[{\"name\":\"zcm\",\"__id\":\"111\"}]", A.class);

    System.out.println(a1);


}


private static final class A{


    private Long id;

    private String name;

    public A() {
    }

    public A(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

}`

gougouzcm avatar Aug 17 '22 06:08 gougouzcm