我最近升级到Retrofit 2,这样做之后,API响应的某些部分突然根本无法映射。我到处都是空值。
但是,有些零件可以映射...我看不到任何图案。
以下是示例回复:
homeListEntities": [
{
"_id": "5bcdf558b876ea01003ff581",
"text": "Camp Care Package!",
"subText": "Build your own!",
"position": 0,
"action": {
"_id": "5bcdf558b876ea01003ff582",
"entityType": 22,
"references": [
{
"referenceType": 12,
"product": null,
"variant": null,
"productId": null,
"variantId": null,
"category": null,
"softCategory": null,
"orderId": null,
"url": null,
"promoCode": null,
"searchTerm": null,
"brandId": null,
"occassionId": "5aec8040bb944d0100d14038",
"_id": "5bcdf571d43cea01005a18e2"
}
],
"referenceClientTitle": ""
},
所有主列表实体均正确映射。 ID,文本,子文本和位置映射正确。但是,动作根本无法映射。只是空的。
这是主页列表实体类:
public final class BXHomeList extends BXBaseObject {
private static final long serialVersionUID = -1L;
@SerializedName("_id")
private String id;
private String text;
private String subText;
private int position;
private int isSelectableNum;
private BXActionInfo action;
@SerializedName("imageV2")
private BXHomeListImage image;
private boolean isExpressHLE;
}
这是动作类:
public final class BXActionInfo extends BXBaseObject {
private static final long serialVersionUID = -1;
@SerializedName("_id")
private String id;
@JsonAdapter(ActionEntityTypeJsonAdapter.class)
private ActionEntityType entityType;
private List<BXActionReference> references = null;
private String referenceClientTitle;
}
这两个类都有getter和setter方法,但我不认为应该全部发布。
自从升级Retrofit以来,我还没有碰过这些东西。
为什么“动作”没有映射?