我是新来的Apache Camel 。我能够调用返回一些数据的api,但是我不能将其解组为json。有人能帮我吗?
<recipientList parallelProcessing="true">
<simple>cxfrs://{{tps.partner.get.url}}/_search?pageSize=1000&pageNumber=1</simple>
</recipientList>
<log loggingLevel="DEBUG"
message="invokegetPartnerAPI - response code >> ${header.CamelHttpResponseCode}" />
<log loggingLevel="DEBUG"
message="invokegetPartnerAPI - response body >> ${body}" />
<unmarshal ref="jacksonMapDataFormat1"/>
<process ref="processor"/>
我在以${body}打印时获取数据。下面是打印出来的数据。
invokegetpartnerapi-响应正文>>{“total”:1,“content”:[{“id”:trn:tesco:特拉迪ngpartner:uuid:9b5a3d70-cc18-40bf-994a-4bc39f21a4a0,“partnername”:“nichol beauty products ltd”,“commercialpartnerstatus”:“active”,“source”:{“id”:“49841323”,“name”:“eqos”}}],“pagenumber”:1,“pagesize”:1000,“totalelements”:1,“totalpages”:1}
但是,当我试图把它解编到我自己的对象时,我却做不到。
pojo类
public class EQOSSupplierJSON implements Serializable {
@JsonProperty("total")
private String total;
@JsonProperty("content")
private content[] content;
@JsonProperty("pageNumber")
private String pageNumber;
@JsonProperty("pageSize")
private String pageSize;
@JsonProperty("totalPages")
private String totalPages;
@JsonProperty("totalElements")
private String totalElements;
public String getTotalElements() {
return totalElements;
}
public void setTotalElements(String totalElements) {
this.totalElements = totalElements;
}
public EQOSSupplierJSON.content[] getContent() {
return content;
}
public void setContent(EQOSSupplierJSON.content[] content) {
this.content = content;
}
public String getPageNumber() {
return pageNumber;
}
public void setPageNumber(String pageNumber) {
this.pageNumber = pageNumber;
}
public String getPageSize() {
return pageSize;
}
public void setPageSize(String pageSize) {
this.pageSize = pageSize;
}
public String getTotalPages() {
return totalPages;
}
public void setTotalPages(String totalPages) {
this.totalPages = totalPages;
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
@Override
public String toString() {
return "EQOSSupplierJSON{" +
"total='" + total + '\'' +
", content=" + Arrays.toString(content) +
", pageNumber='" + pageNumber + '\'' +
", pageSize='" + pageSize + '\'' +
", totalPages='" + totalPages + '\'' +
", totalElements='" + totalElements + '\'' +
'}';
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class SourceSystem {
@JsonProperty("id")
private String id;
@JsonProperty("name")
private String name;
public SourceSystem() {
}
public SourceSystem(String id, String name) {
this.id = id;
this.name = name;
}
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;
}
@Override
public String toString() {
return "SourceSystem{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
'}';
}
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class content {
@JsonProperty("id")
private String id;
@JsonProperty("partnerName")
private String partnerName;
@JsonProperty("commercialPartnerStatus")
private String commercialPartnerStatus;
@JsonProperty("source")
private EQOSSupplierJSON.SourceSystem source;
public void addSource(String id, String name) {
source = new EQOSSupplierJSON.SourceSystem(id, name);
}
public EQOSSupplierJSON.SourceSystem getSource() {
return source;
}
public void setSource(EQOSSupplierJSON.SourceSystem source) {
this.source = source;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPartnerName() {
return partnerName;
}
public void setPartnerName(String partnerName) {
this.partnerName = partnerName;
}
public String getCommercialPartnerStatus() {
return commercialPartnerStatus;
}
public void setCommercialPartnerStatus(String commercialPartnerStatus) {
this.commercialPartnerStatus = commercialPartnerStatus;
}
@Override
public String toString() {
return "content{" +
"id='" + id + '\'' +
", partnerName='" + partnerName + '\'' +
", commercialPartnerStatus='" + commercialPartnerStatus + '\'' +
", source=" + source +
'}';
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!