Here is my json:
{
\"data\": [
{
\"comment\": \"3541\",
\"datetime\": \"2016-01-01\"
}
]
}
Here is model:
If usage of custom TypeScript transformer is possible, ts-transformer-dates could be used:
import { toDates } from 'ts-transformer-dates';
const value = {
"data": [
{
"comment": "3541",
"datetime": "2016-01-01"
}
]
};
export class Job {
constructor(comment:string, datetime:Date) {
this.comment = comment;
this.datetime = datetime;
}
comment:string;
datetime:Date;
}
console.log(toDates<{data:Job[]}>(value));
Output:
{ data: [ { comment: '3541', datetime: 2016-01-01T00:00:00.000Z } ] }