打电话给API
我现在创建一个POJO来映射Json响应
@JsonInclude(JsonInclude.Include.NON_NULL)
JsonIgnoreProperties(ignoreUnknown = true)
public class ResponseBricks<T>{
public ResponseBricks<T>(@JsonProperty("location") Location location,
@JsonProperty("properties") Properties properties,
@JsonProperty("error") AzureError error) {
this.location = location;
this.properties = properties;
this.error = error;
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public T getProperties() {
return properties;
}
public void setProperties(T properties) {
this.properties = properties;
}
public AzureError getError() {
return error;
}
public void setErrorAzureError error) {
this.error = error;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Response getResponse() {
return response;
}
public void setResponse(Response response) {
this.response = response;
}
private Location location;
private T properties;
private String id;
private String name;
private AzureError error;
private Response response;
}
现在我需要来自响应的标题,因此包括在内
private Response response;
但是,响应未完全映射到azure调用的响应,并且Response为null。如果我将响应保持为响应而不是我的自定义POJO,我可以获取标题。但是有没有办法使用自定义pojo并将响应作为变量放在其中?
所以尝试了这一点。唯一的方法是使用Response.Custom Pojo进行响应,不会给出标题。响应有很多方法不仅可以获取标题,还可以获取正文。