我试图从来自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调用返回的所有属性。
我可能误解了模型对象的概念,请纠正我。
发布于 2017-03-08 15:35:27
不,你得做这件事。创建一个新对象,设置值,返回它。
https://stackoverflow.com/questions/42664803
复制相似问题