我有一个类应该根据头请求进行反序列化。
如果标题是V1版本,ww应输出Product类的信息字段,如String。否则它会输出一个Info对象。
是否有其他解决方案可以执行此操作,而是复制类?
public class Product{
private String name;
private Integer id;
private Info information;
}
public class Info{
private String generalInfo;
private String fullDescription;
private String code;
}
public class Product{
private String name;
private Integer id;
private String information;
}
当使用INFO对象时,在JSON之上,当信息是字符串时。
{
"name": "Paul",
"id": "123123,
"information": {
"generalInfo":"Business Product",
"fullDescription":"23",
"code":"9487987289929222-3"
}
}
{
"name": "Paul",
"id": "123123,
"information": "Business Product - 23 - 9487987289929222-3 "
}