我正在尝试从API
{
"claims": [
{
"amount": 3953,
"dateReceived": "2014-8-02",
"groupCode": "3947",
"id": 544477,
"invoiceDate": "2014-8-01",
"invoiceNumber": "43443433634",
"memberNames": "FFFEE GTFSS",
"memberNumber": "FD56DFD6F",
"providerCode": "241",
"serviceTags": {
"diagnosis": "jkfkfgkh",
"quantity": "6",
"serviceAmount": "3434",
"serviceCode": "097090",
"serviceCodeType": "69696",
"serviceDescription": "twertret",
"serviceType": "ghkgk",
"transactionId": 58
}
}
]
}
但我一直收到以下错误:
Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "claims" , not marked as ignorable (10 known properties: , "memberNumber", "groupCode", "memberNames", "serviceTags", "dateReceived", "invoiceNumber", "amount", "id", "invoiceDate", "providerCode"])Unrecognized field "claims"
以下是我的课程:
public class Claim {
private int id;
private String groupCode;
private String providerCode;
private String memberNumber;
private String memberNames;
private Date invoiceDate;
private long amount;
private Date dateReceived;
private String invoiceNumber;
private ServiceTag serviceTags ;
public Claim() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public ServiceTag getServiceTags() {
return serviceTags;
}
public void setServiceTags(ServiceTag serviceTags) {
this.serviceTags = serviceTags;
}
public String getGroupCode() {
return groupCode;
}
public void setGroupCode(String groupCode) {
this.groupCode = groupCode;
}
public String getProviderCode() {
return providerCode;
}
public void setProviderCode(String providerCode) {
this.providerCode = providerCode;
}
public String getMemberNumber() {
return memberNumber;
}
public void setMemberNumber(String memberNumber) {
this.memberNumber = memberNumber;
}
public String getMemberNames() {
return memberNames;
}
public void setMemberNames(String memberNames) {
this.memberNames = memberNames;
}
public Date getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
}
public long getAmount() {
return amount;
}
public void setAmount(long amount) {
this.amount = amount;
}
public Date getDateReceived() {
return dateReceived;
}
public void setDateReceived(Date dateReceived) {
this.dateReceived = dateReceived;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public Claim(int provider_claim_id, String policy_number, String provider_code, String membership_number, String member_name, Date transaction_date, Long amount, Date date_received, String smart_invoice_nr, ServiceTag sservicetag){
this.id = provider_claim_id;
this.groupCode = policy_number;
this.providerCode = provider_code;
this.memberNumber = membership_number;
this.memberNames = member_name;
this.invoiceDate = transaction_date;
this.amount = amount;
this.dateReceived = date_received;
this.invoiceNumber = smart_invoice_nr;
this.serviceTags = sservicetag;
}
@Override
public String toString() {
return String.format("name=%s, organisation=%s", this.memberNames, this.memberNumber);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((memberNames == null) ? 0 : memberNames.hashCode());
return result;
}
@Override
// Claim objects are equal if they have the same name.
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Claim other = (Claim) obj;
if (memberNames == null) {
if (other.memberNames != null)
return false;
} else if (!memberNames.equals(other.memberNames))
return false;
return true;
}
}
这是另一个班级
public class ServiceTag {
private int transactionId;
private String serviceDescription;
private String serviceCode;
private String serviceAmount;
private String quantity;
private String diagnosis;
private String serviceType;
private String serviceCodeType;
private String serviceDate;
public ServiceTag(
int transactionId,
String serviceDescription,
String serviceCode,
String serviceAmount,
String quantity,
String diagnosis,
String serviceType,
String serviceCodeType,
String serviceDate
) {
this.transactionId = transactionId;
this.serviceDescription = serviceDescription;
this.serviceCode = serviceCode;
this.serviceAmount = serviceAmount;
this.quantity = quantity;
this.diagnosis = diagnosis;
this.serviceType = serviceType;
this.serviceCodeType = serviceCodeType;
}
public int getTransactionId() {
return transactionId;
}
public void setTransactionId(int transactionId) {
this.transactionId = transactionId;
}
public String getServiceDescription() {
return serviceDescription;
}
public void setServiceDescription(String serviceDescription) {
this.serviceDescription = serviceDescription;
}
public String getServiceCode() {
return serviceCode;
}
public void setServiceCode(String serviceCode) {
this.serviceCode = serviceCode;
}
public String getServiceAmount() {
return serviceAmount;
}
public void setServiceAmount(String serviceAmount) {
this.serviceAmount = serviceAmount;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getDiagnosis() {
return diagnosis;
}
public void setDiagnosis(String diagnosis) {
this.diagnosis = diagnosis;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public String getServiceCodeType() {
return serviceCodeType;
}
public void setServiceCodeType(String serviceCodeType) {
this.serviceCodeType = serviceCodeType;
}
}
知道如何修改上面的类以正确地反序列化这个JSON
吗?