我试图从json中获取model object
来自http response call
。
以下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; }
因为我不需要从休息电话中提供的所有属性。
因为我计划从缓存中省略不必要的属性,并通过删除这些属性来减少内存。为此,我把我的服务写成了打击。
return this.http.request(path, requestOptions).map((response: Response) => {
return response.json() as models.SupplierBrief;
});
但SupplierBrief
仍然包含休息调用返回的所有属性。
我可能会误解模型对象的概念,请指正。
答案 0 :(得分:0)