如何在java中创建一个自定义@jsonDeserializer类

我有一个Java类。 这与许多其他Java类有关。 我想反序列化这个类。 请帮助我反序列化这个类。 我的班就是这样..

@Entity @Table(name =“A”,uniqueConstraints = @UniqueConstraint(columnNames = {“name”}))@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property =“@_ refid”)@JsonDeserialize(using = ADeSerializer。类)public class A {

@Column(name = "name")
private String name;

@Column(name = "DESCRIPTION")
private String description;

//

@ManyToMany(cascade={CascadeType.REMOVE, CascadeType.MERGE},fetch=FetchType.EAGER)
@JoinTable(
        name="B",
        joinColumns={@JoinColumn(name="Aname")},
        inverseJoinColumns={@JoinColumn(name="Bname", unique=true)}
    )
@Fetch(FetchMode.SUBSELECT)
private Set<C> cs;

@ManyToMany(cascade={CascadeType.MERGE},fetch=FetchType.EAGER)
@JoinTable(
        name="D",
        joinColumns=@JoinColumn(name="Aname"),
        inverseJoinColumns=@JoinColumn(name="Ename")
    )
@Fetch(FetchMode.SUBSELECT)
private Set<E> Es;

@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
@ManyToMany(cascade={CascadeType.ALL, CascadeType.MERGE},fetch=FetchType.EAGER)
@JoinTable(
        name="F",
        joinColumns=@JoinColumn(name="Aname"),
        inverseJoinColumns=@JoinColumn(name="Fname")
    )
@Fetch(FetchMode.SUBSELECT)
private Set<F> Fs;



// Getters and setters

}

清楚地说...

 Class A {
        Object of Class B;
        Object of Class C {
                  Set<ClassB> bs;
               Objects of Class C;
               Object of Class A
          }
       other local variables;

      Objects of Class D{
             set<ClassB> ds;
        }

// Getters和setters

}

我的休息服务是

@RequestMapping(value =“/ saveA”,method = RequestMethod.POST)public @ResponseBody MIResponse saveA(@RequestBody A a)throws Exception {

    return null;
}
链接地址: http://www.djcxy.com/p/48909.html

上一篇: How to create a custom @jsonDeserializer class in java

下一篇: CURL modifying request headers