を存在するフィールドを認識しないは、ジャクソンがだからここ
{"totalSize":46,"done":true,"records":[{"Name":"Wamu I","Start_Date__c":"2016-09-26T16:56:10.000+0000","Status__c":"Completed","Type__c":"Your were expecting success, but In reality it was I, Dio!!!"}]}
そして、ここでは私の2つのエンティティクラスである私のJSONです:私はEsidesiJobEntityにそのJSON文字列をマッピングする際に、何らかの理由で
@JsonIgnoreProperties(ignoreUnknown = true)
public class EsidesiJobEntity {
@JsonProperty("totalSize")
private @Getter @Setter Integer totalSize;
@JsonProperty("done")
private @Getter @Setter Boolean isDone;
@JsonProperty("records")
private @Getter @Setter List<KarsEntity> records;
@Override
@JsonIgnore
public String toString(){
List<String> recordsObjectString = new ArrayList<String>();
this.records.forEach((record) ->
{
recordsObjectString.add(record.toString());
});
return "{ totalSize:"+this.totalSize+", isDone:"+this.isDone+", records:["+recordsObjectString.toString()+"]";
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
public class KarsEntity {
@JsonProperty("Name")
private @Getter @Setter String name;
@JsonProperty("Start_Date__c")
private @Getter @Setter String startDate;
@JsonProperty("Status__c")
private @Getter @Setter String status;
@Override
public String toString(){
return "{ name:"+this.name+", startDate:"+this.startDate+", status:"+this.status+"}";
}
}
、I次のエラーを取得する:
Unrecognized field "totalSize"
それは間違いなく両方でJSONとエンティティの両方に存在します!
EsidesiEntity apexJobResponseEntity;
ObjectMapper apexMapper = new ObjectMapper();
try {
apexJobResponseEntity = apexMapper.readValue(apexResponseString, EsidesiEntity.class);
} ...
アム私は本当に基本的な何かが欠け:
ここで私は参照のためのエンティティへの文字列をマップするために書いたコードですか?
(ところで、クラス/エンティティ名に、いくつかの矛盾がある場合、その私は、オンラインでそれらを投稿する前に、それらを名前を変更したからです。私が知っていると私はそれを見るように私はそれらを修正します。)
感謝を!
。 –
apexResponseとは何ですか?これはあなたのjsonの文字列ですか? –
実際には、apexResponseは文字列で、apexJobResponseがオブジェクトです。私はこれを少し明確にしましょう。 – Maz