@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
该注解的作用是:使用属性名称来转json。 防止不规范的属性报错,比如 app_id
@JsonIgnoreProperties(ignoreUnknown = true)
该注解的作用是:在进行json转对象是,防止传入的json串包含不存在的属性导致报错。
案例:
1 @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
@JsonIgnoreProperties(ignoreUnknown = true)
public class UnifiedPayOrderResponse {
private String code;
private String message;
private String main_order_code;
private String app_id;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMain_order_code() {
return main_order_code;
}
public void setMain_order_code(String main_order_code) {
this.main_order_code = main_order_code;
}
public String getApp_id() {
return app_id;
}
public void setApp_id(String app_id) {
this.app_id = app_id;
}
}