Json数组的反序列化

时间:2015-12-04 15:07:52

标签: json jackson deserialization

我有一个json数组,我通过这样休息:

 ClientResponse<String> response = request.get();
 response.getEntity(String.class)

因此json字符串是正确的并包含对象列表。现在我试着用这个:

 List<TypeAbsenceCompteurs> typeAbsenceCompteursList = new ObjectMapper().readValue(response.getEntity(String.class), new TypeReference<List<TypeAbsenceCompteurs>>() {});

这不完全有效。我得到列表中每个对象内的对象列表和浮点数。但是我在列表的对象中有一个对象,而且这个对象没有被反序列化。

public class TypeAbsenceCompteurs implements Serializable{

private static final long serialVersionUID = 5473968894324284477L;

@JsonProperty
private TypeAbsence typeAbsence;
private Float[] congesAcquis;
private Float congesPris;
private Float[] congesAcquisPlanifies;
private Float congesPrisPlanifies;

....

TypeAbsence未反序列化。它的每个属性都是null或0

Json String:

[{"typeAbsence":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-06-01","dateFin":"2010-05-31","nbJoursAcquis":2.0,"periodiciteJoursAcquis":0,"reinitialisationAuto":false,"typeAbsenceCible":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-06-01","dateFin":"2010-05-31","nbJoursAcquis":0.0,"periodiciteJoursAcquis":null,"reinitialisationAuto":true,"typeAbsenceCible":null,"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#149830","textColor":"#ffffff","valuationActivated":false,"ordre":1,"suspendedAbsenceTypesId":[],"deletable":false,"key":57,"label":"Congés N-1 RàP"},"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#1f8cbd","textColor":"#ffffff","valuationActivated":false,"ordre":0,"suspendedAbsenceTypesId":[],"deletable":false,"key":56,"label":"Congés N 2"},"congesAcquis":[2.0,0.0],"congesPris":0.0,"congesAcquisPlanifies":[24.0,2.0],"congesPrisPlanifies":0.0},{"typeAbsence":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-06-01","dateFin":"2010-05-31","nbJoursAcquis":0.0,"periodiciteJoursAcquis":null,"reinitialisationAuto":true,"typeAbsenceCible":null,"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#149830","textColor":"#ffffff","valuationActivated":false,"ordre":1,"suspendedAbsenceTypesId":[],"deletable":false,"key":57,"label":"Congés N-1 RàP"},"congesAcquis":[24.0,0.0],"congesPris":0.0,"congesAcquisPlanifies":[24.0,0.0],"congesPrisPlanifies":0.0},{"typeAbsence":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-01-01","dateFin":"2010-12-31","nbJoursAcquis":10.0,"periodiciteJoursAcquis":3,"reinitialisationAuto":false,"typeAbsenceCible":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-01-01","dateFin":"2010-12-31","nbJoursAcquis":0.0,"periodiciteJoursAcquis":0,"reinitialisationAuto":true,"typeAbsenceCible":null,"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#787878","textColor":"#ffffff","valuationActivated":false,"ordre":3,"suspendedAbsenceTypesId":[],"deletable":false,"key":63,"label":"Congé annuelle RàP N-1"},"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#ba3ebb","textColor":"#ffffff","valuationActivated":false,"ordre":2,"suspendedAbsenceTypesId":[],"deletable":false,"key":61,"label":"Congé annuelle N 10"},"congesAcquis":[10.0,0.0],"congesPris":0.0,"congesAcquisPlanifies":[20.0,10.0],"congesPrisPlanifies":0.0},{"typeAbsence":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-06-01","dateFin":"2010-05-31","nbJoursAcquis":2.0,"periodiciteJoursAcquis":0,"reinitialisationAuto":false,"typeAbsenceCible":null,"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#8e436b","textColor":"#ffffff","valuationActivated":false,"ordre":4,"suspendedAbsenceTypesId":[],"deletable":false,"key":58,"label":"Congé mensuel simple 2"},"congesAcquis":[2.0,0.0],"congesPris":0.0,"congesAcquisPlanifies":[24.0,2.0],"congesPrisPlanifies":0.0},{"typeAbsence":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-01-01","dateFin":"2010-12-31","nbJoursAcquis":10.0,"periodiciteJoursAcquis":3,"reinitialisationAuto":false,"typeAbsenceCible":null,"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#f03030","textColor":"#ffffff","valuationActivated":false,"ordre":5,"suspendedAbsenceTypesId":[],"deletable":false,"key":59,"label":"Congé annuel simple 10"},"congesAcquis":[10.0,0.0],"congesPris":0.0,"congesAcquisPlanifies":[10.0,0.0],"congesPrisPlanifies":0.0},{"typeAbsence":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-06-01","dateFin":"2010-05-31","nbJoursAcquis":2.0,"periodiciteJoursAcquis":0,"reinitialisationAuto":true,"typeAbsenceCible":null,"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#b7cc00","textColor":"#ffffff","valuationActivated":false,"ordre":6,"suspendedAbsenceTypesId":[],"deletable":false,"key":60,"label":"Congé mensuel RàP 2"},"congesAcquis":[26.0,0.0],"congesPris":0.0,"congesAcquisPlanifies":[48.0,2.0],"congesPrisPlanifies":0.0},{"typeAbsence":{"nombreMaxParAn":0.0,"nbMaxParMois":0.0,"activiteFacturee":false,"validationAuto":false,"typeAbsence_sync_Id":0,"dependsOnWorkContract":false,"offsetMonthFromHiringDate":0,"offsetYearFromHiringDate":0,"dateDebut":"2010-01-01","dateFin":"2010-12-31","nbJoursAcquis":10.0,"periodiciteJoursAcquis":3,"reinitialisationAuto":true,"typeAbsenceCible":null,"baseCalcul":false,"type":0,"alertOrBlockHolidayCounter":0,"alertOrBlockResteAPrendre":0,"color":"#0cae34","textColor":"#ffffff","valuationActivated":false,"ordre":7,"suspendedAbsenceTypesId":[],"deletable":false,"key":62,"label":"Congé annuel RàP"},"congesAcquis":[0.0,0.0],"congesPris":0.0,"congesAcquisPlanifies":[20.0,10.0],"congesPrisPlanifies":0.0}]

0 个答案:

没有答案