将json日期映射到Typescript类属性时保留字符串类型

将json日期映射到Typescript类属性时保留字符串类型,json,angular,typescript,iso8601,Json,Angular,Typescript,Iso8601,我有一个Angular2应用程序,它使用服务从Web Api获取数据,如下所示: export class Customer { public customerId: number; public customerName: string; public dateOfbirth: Date; } public getCustomer(customerId: number): Observable<Customer> { let url = this

我有一个Angular2应用程序,它使用服务从Web Api获取数据,如下所示:

export class Customer {
    public customerId: number;
    public customerName: string;
    public dateOfbirth: Date;
}

public getCustomer(customerId: number): Observable<Customer> {

    let url = this.config.baseUrl + "http://BlahBlah/Customer/Get/" + customerId;

    return this.http
        .get(url)
        .map(res => res.json());

}
customerId: 1
customerName: "John Wilkes"
dateOfBirth: "1998-11-04T00:00:00"

问题是dateOfBirth正在转换为字符串而不是
Date
类型,尽管它在Customer类声明中声明为
Date
。如何将其转换为默认行为的
日期
类型,而不必在代码中手动转换它们?

新日期(res.dateOfBirth)
要通过网络发送,必须以某种方式序列化
日期
。我会使用一个数字,以毫秒为单位的Unix历元(
Date.getTime()
),以避免任何时区问题。我希望避免手动转换从服务器返回的每个数据。考虑到这一点,问题在于RxJs映射函数。地图似乎可以毫无问题地处理数字和布尔值,但无法识别和保存日期。