【发布时间】:2017-07-28 15:15:03
【问题描述】:
我试图从来自http response call的json中获取model object。
JSON下方是http response的正文部分,
{
"dataType": "RWSupplier",
"partyName": "Lifecare Pharmaceuticals",
"partyShortName": null,
"partySecondaryName": null,
"partySecondaryShortName": null,
"sortingName": "Lifecare Pharma",
"mailingName": null,
"entityType": "SP",
"partyType": "OG",
"partySubType": null,
"extPartyId": null,
"comments": null,
"prGenderType": null,
"prBirthDate": null,
"prSalutation": null,
"statusCode": null,
"lastUpdateDate": "2017-03-06T04:30:00.000+0000",
"lastUpdateUser": "RwAdmin",
"tinNum": "33450701833",
"cstNum": "790052 dt. 4/4/2001",
"stNum": null,
"dlNum1": "5324/MIII/20B",
"dlNum2": "5205/MIII/21B",
"limitList": [ ],
"tagList": [ ],
"buId": "510",
"partyId": "SP001011001" }
我为上面的JSON数据创建了如下接口,
export interface SupplierBrief {
dataType: string;
partyId: string;
buId: string;
partyName: string;
statusCode: string;
comments: string; }
因为我不需要从 rest 调用提供的所有属性。
因为我计划从缓存中省略不必要的属性,并通过删除这些属性来减少内存。为此,我写了我的服务作为给定的打击。
return this.http.request(path, requestOptions).map((response: Response) => {
return response.json() as models.SupplierBrief;
});
但SupplierBrief 仍然包含所有由 rest 调用返回的属性。
我可能对模型对象的概念有误解,请指正。
【问题讨论】:
标签: json typescript angular2-routing